Documentation ¶
Index ¶
- Constants
- Variables
- func EstimateSerializeSize(inputCount int, txOuts []*wire.TxOut, addChangeOutput bool, ...) int
- func SumOutputSerializeSizes(outputs []*wire.TxOut) (serializeSize int)
- type BitcoinWallet
- func (w *BitcoinWallet) AddTransactionListener(callback func(wi.TransactionCallback))
- func (w *BitcoinWallet) AddWatchedAddresses(addrs ...btc.Address) error
- func (w *BitcoinWallet) AddressToScript(addr btc.Address) ([]byte, error)
- func (w *BitcoinWallet) AssociateTransactionWithOrder(cb wi.TransactionCallback)
- func (w *BitcoinWallet) Balance() (wi.CurrencyValue, wi.CurrencyValue)
- func (w *BitcoinWallet) Broadcast(tx *wire.MsgTx) error
- func (w *BitcoinWallet) BumpFee(txid chainhash.Hash) (*chainhash.Hash, error)
- func (w *BitcoinWallet) ChainTip() (uint32, chainhash.Hash)
- func (w *BitcoinWallet) ChildKey(keyBytes []byte, chaincode []byte, isPrivateKey bool) (*hd.ExtendedKey, error)
- func (w *BitcoinWallet) Close()
- func (w *BitcoinWallet) CreateMultisigSignature(ins []wi.TransactionInput, outs []wi.TransactionOutput, key *hd.ExtendedKey, ...) ([]wi.Signature, error)
- func (w *BitcoinWallet) CurrencyCode() string
- func (w *BitcoinWallet) CurrentAddress(purpose wi.KeyPurpose) btc.Address
- func (w *BitcoinWallet) DecodeAddress(addr string) (btc.Address, error)
- func (w *BitcoinWallet) DumpTables(wr io.Writer)
- func (w *BitcoinWallet) EstimateFee(ins []wi.TransactionInput, outs []wi.TransactionOutput, feePerByte big.Int) big.Int
- func (w *BitcoinWallet) EstimateSpendFee(amount big.Int, feeLevel wi.FeeLevel) (big.Int, error)
- func (w *BitcoinWallet) ExchangeRates() wi.ExchangeRates
- func (w *BitcoinWallet) GenerateMultisigScript(keys []hd.ExtendedKey, threshold int, timeout time.Duration, ...) (addr btc.Address, redeemScript []byte, err error)
- func (w *BitcoinWallet) GetConfirmations(txid chainhash.Hash) (uint32, uint32, error)
- func (w *BitcoinWallet) GetFeePerByte(feeLevel wi.FeeLevel) big.Int
- func (w *BitcoinWallet) GetTransaction(txid chainhash.Hash) (wi.Txn, error)
- func (w *BitcoinWallet) HasKey(addr btc.Address) bool
- func (w *BitcoinWallet) IsDust(amount big.Int) bool
- func (w *BitcoinWallet) MasterPrivateKey() *hd.ExtendedKey
- func (w *BitcoinWallet) MasterPublicKey() *hd.ExtendedKey
- func (w *BitcoinWallet) Multisign(ins []wi.TransactionInput, outs []wi.TransactionOutput, sigs1 []wi.Signature, ...) ([]byte, error)
- func (w *BitcoinWallet) NewAddress(purpose wi.KeyPurpose) btc.Address
- func (w *BitcoinWallet) Params() *chaincfg.Params
- func (w *BitcoinWallet) ReSyncBlockchain(fromTime time.Time)
- func (w *BitcoinWallet) ScriptToAddress(script []byte) (btc.Address, error)
- func (w *BitcoinWallet) Spend(amount big.Int, addr btc.Address, feeLevel wi.FeeLevel, referenceID string, ...) (*chainhash.Hash, error)
- func (w *BitcoinWallet) Start()
- func (w *BitcoinWallet) SweepAddress(ins []wi.TransactionInput, address *btc.Address, key *hd.ExtendedKey, ...) (*chainhash.Hash, error)
- func (w *BitcoinWallet) Transactions() ([]wi.Txn, error)
- type InputType
Constants ¶
View Source
const ( // RedeemP2PKHSigScriptSize is the worst case (largest) serialize size // of a transaction input script that redeems a compressed P2PKH output. // It is calculated as: // // - OP_DATA_73 // - 72 bytes DER signature + 1 byte sighash // - OP_DATA_33 // - 33 bytes serialized compressed pubkey RedeemP2PKHSigScriptSize = 1 + 73 + 1 + 33 // RedeemP2SHMultisigSigScriptSize is the worst case (largest) serialize size // of a transaction input script that redeems a 2 of 3 P2SH multisig output with compressed keys. // It is calculated as: // // - OP_0 // - OP_DATA_72 // - 72 bytes DER signature // - OP_DATA_72 // - 72 bytes DER signature // - OP_PUSHDATA // - OP_2 // - OP_DATA_33 // - 33 bytes serialized compressed pubkey // - OP_DATA_33 // - 33 bytes serialized compressed pubkey // - OP_DATA_33 // - 33 bytes serialized compressed pubkey // - OP3 // - OP_CHECKMULTISIG RedeemP2SH2of3MultisigSigScriptSize = 1 + 1 + 72 + 1 + 72 + 1 + 1 + 1 + 33 + 1 + 33 + 1 + 33 + 1 + 1 // RedeemP2SH1of2MultisigSigScriptSize is the worst case (largest) serialize size // of a transaction input script that redeems a 1 of 2 P2SH multisig output with compressed keys. // It is calculated as: // // - OP_0 // - OP_DATA_72 // - 72 bytes DER signature // - OP_PUSHDATA // - OP_1 // - OP_DATA_33 // - 33 bytes serialized compressed pubkey // - OP_DATA_33 // - 33 bytes serialized compressed pubkey // - OP2 // - OP_CHECKMULTISIG RedeemP2SH1of2MultisigSigScriptSize = 1 + 1 + 72 + 1 + 1 + 1 + 33 + 1 + 33 + 1 + 1 // RedeemP2SHMultisigTimelock1SigScriptSize is the worst case (largest) serialize size // of a transaction input script that redeems a compressed P2SH timelocked multisig using the timeout. // It is calculated as: // // - OP_DATA_72 // - 72 bytes DER signature // - OP_0 // - OP_PUSHDATA // - OP_IF // - OP_2 // - OP_DATA_33 // - 33 bytes serialized compressed pubkey // - OP_DATA_33 // - 33 bytes serialized compressed pubkey // - OP_DATA_33 // - 33 bytes serialized compressed pubkey // - OP3 // - OP_CHECKMULTISIG // - OP_ELSE // - OP_PUSHDATA // - 2 byte block height // - OP_CHECKSEQUENCEVERIFY // - OP_DROP // - OP_DATA_33 // - 33 bytes serialized compressed pubkey // - OP_CHECKSIG // - OP_ENDIF RedeemP2SHMultisigTimelock1SigScriptSize = 1 + 72 + 1 + 1 + 1 + 1 + 1 + 33 + 1 + 33 + 1 + 33 + 1 + 1 + 1 + 1 + 2 + 1 + 1 + 1 + 33 + 1 + 1 // RedeemP2SHMultisigTimelock2SigScriptSize is the worst case (largest) serialize size // of a transaction input script that redeems a compressed P2SH timelocked multisig without using the timeout. // It is calculated as: // // - OP_0 // - OP_DATA_72 // - 72 bytes DER signature // - OP_DATA_72 // - 72 bytes DER signature // - OP_1 // - OP_PUSHDATA // - OP_IF // - OP_2 // - OP_DATA_33 // - 33 bytes serialized compressed pubkey // - OP_DATA_33 // - 33 bytes serialized compressed pubkey // - OP_DATA_33 // - 33 bytes serialized compressed pubkey // - OP3 // - OP_CHECKMULTISIG // - OP_ELSE // - OP_PUSHDATA // - 2 byte block height // - OP_CHECKSEQUENCEVERIFY // - OP_DROP // - OP_DATA_33 // - 33 bytes serialized compressed pubkey // - OP_CHECKSIG // - OP_ENDIF RedeemP2SHMultisigTimelock2SigScriptSize = 1 + 1 + 72 + +1 + 72 + 1 + 1 + 1 + 1 + 1 + 33 + 1 + 33 + 1 + 33 + 1 + 1 + 1 + 1 + 2 + 1 + 1 + 1 + 33 + 1 + 1 // P2PKHPkScriptSize is the size of a transaction output script that // pays to a compressed pubkey hash. It is calculated as: // // - OP_DUP // - OP_HASH160 // - OP_DATA_20 // - 20 bytes pubkey hash // - OP_EQUALVERIFY // - OP_CHECKSIG P2PKHPkScriptSize = 1 + 1 + 1 + 20 + 1 + 1 // RedeemP2PKHInputSize is the worst case (largest) serialize size of a // transaction input redeeming a compressed P2PKH output. It is // calculated as: // // - 32 bytes previous tx // - 4 bytes output index // - 1 byte script len // - signature script // - 4 bytes sequence RedeemP2PKHInputSize = 32 + 4 + 1 + RedeemP2PKHSigScriptSize + 4 // RedeemP2SH2of3MultisigInputSize is the worst case (largest) serialize size of a // transaction input redeeming a compressed P2SH 2 of 3 multisig output. It is // calculated as: // // - 32 bytes previous tx // - 4 bytes output index // - 1 byte script len // - 4 bytes sequence /// - witness discounted signature script RedeemP2SH2of3MultisigInputSize = 32 + 4 + 1 + 4 + (RedeemP2SH2of3MultisigSigScriptSize / 4) // RedeemP2SH1of2MultisigInputSize is the worst case (largest) serialize size of a // transaction input redeeming a compressed P2SH 2 of 3 multisig output. It is // calculated as: // // - 32 bytes previous tx // - 4 bytes output index // - 1 byte script len // - 4 bytes sequence /// - witness discounted signature script RedeemP2SH1of2MultisigInputSize = 32 + 4 + 1 + 4 + (RedeemP2SH1of2MultisigSigScriptSize / 4) // RedeemP2SHMultisigTimelock1InputSize is the worst case (largest) serialize size of a // transaction input redeeming a compressed p2sh timelocked multig output with using the timeout. It is // calculated as: // // - 32 bytes previous tx // - 4 bytes output index // - 1 byte script len // - 4 bytes sequence /// - witness discounted signature script RedeemP2SHMultisigTimelock1InputSize = 32 + 4 + 1 + 4 + (RedeemP2SHMultisigTimelock1SigScriptSize / 4) // RedeemP2SHMultisigTimelock2InputSize is the worst case (largest) serialize size of a // transaction input redeeming a compressed P2SH timelocked multisig output without using the timeout. It is // calculated as: // // - 32 bytes previous tx // - 4 bytes output index // - 1 byte script len // - 4 bytes sequence /// - witness discounted signature script RedeemP2SHMultisigTimelock2InputSize = 32 + 4 + 1 + 4 + (RedeemP2SHMultisigTimelock2SigScriptSize / 4) // P2PKHOutputSize is the serialize size of a transaction output with a // P2PKH output script. It is calculated as: // // - 8 bytes output value // - 1 byte compact int encoding value 25 // - 25 bytes P2PKH output script P2PKHOutputSize = 8 + 1 + P2PKHPkScriptSize )
Worst case script and input/output size estimates.
Variables ¶
View Source
var (
BitcoinCurrencyDefinition = wi.CurrencyDefinition{
Code: "BTC",
Divisibility: 8,
}
)
Functions ¶
func EstimateSerializeSize ¶
func EstimateSerializeSize(inputCount int, txOuts []*wire.TxOut, addChangeOutput bool, inputType InputType) int
EstimateSerializeSize returns a worst case serialize size estimate for a signed transaction that spends inputCount number of compressed P2PKH outputs and contains each transaction output from txOuts. The estimated size is incremented for an additional P2PKH change output if addChangeOutput is true.
func SumOutputSerializeSizes ¶
SumOutputSerializeSizes sums up the serialized size of the supplied outputs.
Types ¶
type BitcoinWallet ¶
type BitcoinWallet struct {
// contains filtered or unexported fields
}
func NewBitcoinWallet ¶
func (*BitcoinWallet) AddTransactionListener ¶
func (w *BitcoinWallet) AddTransactionListener(callback func(wi.TransactionCallback))
func (*BitcoinWallet) AddWatchedAddresses ¶
func (w *BitcoinWallet) AddWatchedAddresses(addrs ...btc.Address) error
func (*BitcoinWallet) AddressToScript ¶
func (w *BitcoinWallet) AddressToScript(addr btc.Address) ([]byte, error)
func (*BitcoinWallet) AssociateTransactionWithOrder ¶
func (w *BitcoinWallet) AssociateTransactionWithOrder(cb wi.TransactionCallback)
AssociateTransactionWithOrder used for ORDER_PAYMENT message
func (*BitcoinWallet) Balance ¶
func (w *BitcoinWallet) Balance() (wi.CurrencyValue, wi.CurrencyValue)
func (*BitcoinWallet) Broadcast ¶
func (w *BitcoinWallet) Broadcast(tx *wire.MsgTx) error
Build a client.Transaction so we can ingest it into the wallet service then broadcast
func (*BitcoinWallet) ChildKey ¶
func (w *BitcoinWallet) ChildKey(keyBytes []byte, chaincode []byte, isPrivateKey bool) (*hd.ExtendedKey, error)
func (*BitcoinWallet) Close ¶
func (w *BitcoinWallet) Close()
func (*BitcoinWallet) CreateMultisigSignature ¶
func (w *BitcoinWallet) CreateMultisigSignature(ins []wi.TransactionInput, outs []wi.TransactionOutput, key *hd.ExtendedKey, redeemScript []byte, feePerByte big.Int) ([]wi.Signature, error)
func (*BitcoinWallet) CurrencyCode ¶
func (w *BitcoinWallet) CurrencyCode() string
func (*BitcoinWallet) CurrentAddress ¶
func (w *BitcoinWallet) CurrentAddress(purpose wi.KeyPurpose) btc.Address
func (*BitcoinWallet) DecodeAddress ¶
func (w *BitcoinWallet) DecodeAddress(addr string) (btc.Address, error)
func (*BitcoinWallet) DumpTables ¶
func (w *BitcoinWallet) DumpTables(wr io.Writer)
func (*BitcoinWallet) EstimateFee ¶
func (w *BitcoinWallet) EstimateFee(ins []wi.TransactionInput, outs []wi.TransactionOutput, feePerByte big.Int) big.Int
func (*BitcoinWallet) EstimateSpendFee ¶
func (*BitcoinWallet) ExchangeRates ¶
func (w *BitcoinWallet) ExchangeRates() wi.ExchangeRates
func (*BitcoinWallet) GenerateMultisigScript ¶
func (w *BitcoinWallet) GenerateMultisigScript(keys []hd.ExtendedKey, threshold int, timeout time.Duration, timeoutKey *hd.ExtendedKey) (addr btc.Address, redeemScript []byte, err error)
func (*BitcoinWallet) GetConfirmations ¶
func (*BitcoinWallet) GetFeePerByte ¶
func (w *BitcoinWallet) GetFeePerByte(feeLevel wi.FeeLevel) big.Int
func (*BitcoinWallet) GetTransaction ¶
func (*BitcoinWallet) MasterPrivateKey ¶
func (w *BitcoinWallet) MasterPrivateKey() *hd.ExtendedKey
func (*BitcoinWallet) MasterPublicKey ¶
func (w *BitcoinWallet) MasterPublicKey() *hd.ExtendedKey
func (*BitcoinWallet) Multisign ¶
func (w *BitcoinWallet) Multisign(ins []wi.TransactionInput, outs []wi.TransactionOutput, sigs1 []wi.Signature, sigs2 []wi.Signature, redeemScript []byte, feePerByte big.Int, broadcast bool) ([]byte, error)
func (*BitcoinWallet) NewAddress ¶
func (w *BitcoinWallet) NewAddress(purpose wi.KeyPurpose) btc.Address
func (*BitcoinWallet) Params ¶
func (w *BitcoinWallet) Params() *chaincfg.Params
func (*BitcoinWallet) ReSyncBlockchain ¶
func (w *BitcoinWallet) ReSyncBlockchain(fromTime time.Time)
func (*BitcoinWallet) ScriptToAddress ¶
func (w *BitcoinWallet) ScriptToAddress(script []byte) (btc.Address, error)
func (*BitcoinWallet) Start ¶
func (w *BitcoinWallet) Start()
func (*BitcoinWallet) SweepAddress ¶
func (w *BitcoinWallet) SweepAddress(ins []wi.TransactionInput, address *btc.Address, key *hd.ExtendedKey, redeemScript *[]byte, feeLevel wi.FeeLevel) (*chainhash.Hash, error)
func (*BitcoinWallet) Transactions ¶
func (w *BitcoinWallet) Transactions() ([]wi.Txn, error)
Click to show internal directories.
Click to hide internal directories.