btc-staking-ts
Description
The btc-staking-ts program is a TypeScript library for the Babylon Bitcoin Staking Protocol. The library provides functions for constructing various Bitcoin transactions, like staking, unbonding, withdrawing, and slashing transactions.
This program is responsible for:
transaction construction — providing functions to compile scripts for different types of Bitcoin transactions based on the defined staking parameters
fee calculation — estimating the transaction fees based on the approximate transaction size
Invariants
Generated Bitcoin transaction scripts must adhere strictly to the protocol's specifications
Estimated fee values for the transaction must be accurate given the correct fee rate
Staking parameters must be used consistently across all transactions types
Test coverage
Cases covered
Transaction construction correctness — staking, unbonding, withdrawal, and slashing transactions are compiled and then checked to ensure they have the correct fields
Transaction validation — tests ensure that transactions fail to build given incorrect parameters or configurations
Cases not covered
Integration tests that execute transactions on a Bitcoin node to ensure correct processing
Attack surface
The attack surface is primarily the input parameters to the various entrypoint functions in the library. Input should be validated to ensure that malicious or incorrect parameters do not result in malformed transaction scripts. This includes both staking parameters and UTXO input data.