Documentation ¶
Index ¶
- Constants
- Variables
- func CalcBlockAvgFeeRate(blockVb *btcjson.GetBlockVerboseTxResult, netParams *chaincfg.Params) (int64, error)
- func CalcDepositorFee(blockVb *btcjson.GetBlockVerboseTxResult, chainID int64, ...) float64
- func DecodeOpReturnMemo(scriptHex string, txid string) ([]byte, bool, error)
- func DecodeScriptP2PKH(scriptHex string, net *chaincfg.Params) (string, error)
- func DecodeScriptP2SH(scriptHex string, net *chaincfg.Params) (string, error)
- func DecodeScriptP2TR(scriptHex string, net *chaincfg.Params) (string, error)
- func DecodeScriptP2WPKH(scriptHex string, net *chaincfg.Params) (string, error)
- func DecodeScriptP2WSH(scriptHex string, net *chaincfg.Params) (string, error)
- func DecodeTSSVout(vout btcjson.Vout, receiverExpected string, chain chains.Chain) (string, int64, error)
- func DepositorFee(satPerByte int64) float64
- func EncodeAddress(hash160 []byte, netID byte) string
- func EstimateOutboundSize(numInputs uint64, payees []btcutil.Address) (uint64, error)
- func FeeRateToSatPerByte(rate float64) *big.Int
- func GetOutputSizeByAddress(to btcutil.Address) (uint64, error)
- func GetSatoshis(btc float64) (int64, error)
- func IsPkScriptP2PKH(script []byte) bool
- func IsPkScriptP2SH(script []byte) bool
- func IsPkScriptP2TR(script []byte) bool
- func IsPkScriptP2WPKH(script []byte) bool
- func IsPkScriptP2WSH(script []byte) bool
- func OutboundSizeDepositor() uint64
- func OutboundSizeWithdrawer() uint64
- func PayToAddrScript(addr btcutil.Address) ([]byte, error)
- func PrettyPrintStruct(val interface{}) (string, error)
- func WiredTxSize(numInputs uint64, numOutputs uint64) uint64
Constants ¶
const ( OutboundBytesMin = uint64(239) // 239vB == EstimateSegWitTxSize(2, 2, toP2WPKH) OutboundBytesMax = uint64(1543) // 1543v == EstimateSegWitTxSize(21, 2, toP2TR) OutboundBytesAvg = uint64(245) // 245vB is a suggested gas limit for zetacore DynamicDepositorFeeHeight = 834500 // DynamicDepositorFeeHeight contains the starting height (Bitcoin mainnet) from which dynamic depositor fee will take effect )
const ( // LengthScriptP2TR is the lenth of P2TR script [OP_1 0x20 <32-byte-hash>] LengthScriptP2TR = 34 // LengthScriptP2WSH is the length of P2WSH script [OP_0 0x20 <32-byte-hash>] LengthScriptP2WSH = 34 // LengthScriptP2WPKH is the length of P2WPKH script [OP_0 0x14 <20-byte-hash>] LengthScriptP2WPKH = 22 // LengthScriptP2SH is the length of P2SH script [OP_HASH160 0x14 <20-byte-hash> OP_EQUAL] LengthScriptP2SH = 23 // LengthScriptP2PKH is the length of P2PKH script [OP_DUP OP_HASH160 0x14 <20-byte-hash> OP_EQUALVERIFY OP_CHECKSIG] LengthScriptP2PKH = 25 )
Variables ¶
var ( // BtcOutboundBytesDepositor is the outbound size incurred by the depositor: 68vB BtcOutboundBytesDepositor = OutboundSizeDepositor() // BtcOutboundBytesWithdrawer is the outbound size incurred by the withdrawer: 177vB BtcOutboundBytesWithdrawer = OutboundSizeWithdrawer() // DefaultDepositorFee is the default depositor fee is 0.00001360 BTC (20 * 68vB / 100000000) // default depositor fee calculation is based on a fixed fee rate of 20 sat/byte just for simplicity. DefaultDepositorFee = DepositorFee(defaultDepositorFeeRate) )
Functions ¶
func CalcBlockAvgFeeRate ¶
func CalcBlockAvgFeeRate(blockVb *btcjson.GetBlockVerboseTxResult, netParams *chaincfg.Params) (int64, error)
CalcBlockAvgFeeRate calculates the average gas rate (in sat/vByte) for a given block
func CalcDepositorFee ¶
func CalcDepositorFee( blockVb *btcjson.GetBlockVerboseTxResult, chainID int64, netParams *chaincfg.Params, logger zerolog.Logger, ) float64
CalcDepositorFee calculates the depositor fee for a given block
func DecodeOpReturnMemo ¶
DecodeOpReturnMemo decodes memo from OP_RETURN script returns (memo, found, error)
func DecodeScriptP2PKH ¶
DecodeScriptP2PKH decodes address from P2PKH script
func DecodeScriptP2SH ¶
DecodeScriptP2SH decodes address from P2SH script
func DecodeScriptP2TR ¶
DecodeScriptP2TR decodes address from P2TR script
func DecodeScriptP2WPKH ¶
DecodeScriptP2WPKH decodes address from P2WPKH script
func DecodeScriptP2WSH ¶
DecodeScriptP2WSH decodes address from P2WSH script
func DecodeTSSVout ¶
func DecodeTSSVout(vout btcjson.Vout, receiverExpected string, chain chains.Chain) (string, int64, error)
DecodeTSSVout decodes receiver and amount from a given TSS vout
func DepositorFee ¶
DepositorFee calculates the depositor fee in BTC for a given sat/byte fee rate Note: the depositor fee is charged in order to cover the cost of spending the deposited UTXO in the future
func EncodeAddress ¶
EncodeAddress returns a human-readable payment address given a ripemd160 hash and netID which encodes the bitcoin network and address type. It is used in both pay-to-pubkey-hash (P2PKH) and pay-to-script-hash (P2SH) address encoding. Note: this function is a copy of the function in btcutil/address.go
func EstimateOutboundSize ¶
EstimateOutboundSize estimates the size of an outbound in vBytes
func FeeRateToSatPerByte ¶
FeeRateToSatPerByte converts a fee rate in BTC/KB to sat/byte.
func GetOutputSizeByAddress ¶
GetOutputSizeByAddress returns the size of a tx output in bytes by the given address
func GetSatoshis ¶
GetSatoshis converts a bitcoin amount to satoshis
func IsPkScriptP2PKH ¶
IsPkScriptP2PKH checks if the given script is a P2PKH script
func IsPkScriptP2SH ¶
IsPkScriptP2SH checks if the given script is a P2SH script
func IsPkScriptP2TR ¶
IsPkScriptP2TR checks if the given script is a P2TR script
func IsPkScriptP2WPKH ¶
IsPkScriptP2WPKH checks if the given script is a P2WPKH script
func IsPkScriptP2WSH ¶
IsPkScriptP2WSH checks if the given script is a P2WSH script
func OutboundSizeDepositor ¶
func OutboundSizeDepositor() uint64
OutboundSizeDepositor returns outbound size (68vB) incurred by the depositor
func OutboundSizeWithdrawer ¶
func OutboundSizeWithdrawer() uint64
OutboundSizeWithdrawer returns outbound size (177vB) incurred by the withdrawer (1 input, 3 outputs)
func PayToAddrScript ¶
PayToAddrScript creates a new script to pay a transaction output to a the specified address.
func PrettyPrintStruct ¶
PrettyPrintStruct returns a pretty-printed string representation of a struct
func WiredTxSize ¶
WiredTxSize calculates the wired tx size in bytes
Types ¶
This section is empty.