Documentation
¶
Index ¶
- Constants
- Variables
- func ValidateAddress(addrress string) bool
- type AddressType
- type BTC
- type CalculateTxSizeData
- type Config
- type GenerateAddressData
- type TxBuilder
- func (s *TxBuilder) AddInput(input TxInput) error
- func (s *TxBuilder) AddOutput(address string, amount decimal.Decimal) error
- func (s *TxBuilder) CalculateTxSize(feePerByte decimal.Decimal) CalculateTxSizeData
- func (s *TxBuilder) EmulateTxSize(feePerByte decimal.Decimal) (CalculateTxSizeData, error)
- func (s *TxBuilder) MsgTx() *wire.MsgTx
- func (s *TxBuilder) SignTx() error
- type TxInput
- type WalletSDK
- func (s WalletSDK) AddressFromPrivateKey(privateKeyWIF string) (string, *btcec.PrivateKey, error)
- func (s WalletSDK) ChainParams() *chaincfg.Params
- func (s WalletSDK) DecodeAddressType(address string) (AddressType, error)
- func (s WalletSDK) GenerateAddress(addressType AddressType, mnemonic, passphrase string, sequenceNumber uint32) (*GenerateAddressData, error)
- func (s WalletSDK) ValidateAddress(address string) bool
Constants ¶
const ( AssetIdentifier = "btc" AssetDecimals = 1e8 )
Variables ¶
var ( ErrInputAlreadyUsed = errors.New("input already used") ErrOutputAlreadyExists = errors.New("output already exists") )
Functions ¶
Types ¶
type AddressType ¶
type AddressType string
AddressType represents the type of a Bitcoin address.
const ( AddressTypeP2PKH AddressType = "P2PKH" // Legacy AddressTypeP2SH AddressType = "P2SH" // SegWit (nested) AddressTypeP2WPKH AddressType = "P2WPKH" // Native SegWit (Bech32) AddressTypeP2TR AddressType = "P2TR" // Taproot )
type BTC ¶
type BTC struct {
WalletSDK *WalletSDK
// contains filtered or unexported fields
}
func (*BTC) EstimateFeePerByte ¶ added in v0.9.13
EstimateFeePerByte returns the current network fee rate in base units per virtual byte estimated by the node. Returns zero if the node does not have enough data for the estimate yet.
func (*BTC) MinRelayFeePerByte ¶ added in v0.9.14
MinRelayFeePerByte returns the lowest fee rate in base units per byte the node accepts into its mempool: the larger of the node relay fee and the current mempool minimum fee. Transactions paying less are rejected with "min relay fee not met".
type CalculateTxSizeData ¶
type Config ¶
type Config struct {
RPCConfig *rpcclient.ConnConfig
}
type GenerateAddressData ¶
type GenerateAddressData struct {
Address btcutil.Address
PublicKey *btcec.PublicKey
PrivateKey *btcec.PrivateKey
PrivateKeyWIF *btcutil.WIF
MasterKey *hdkeychain.ExtendedKey
Sequence uint32
// contains filtered or unexported fields
}
func (GenerateAddressData) AddressPubKey ¶
func (s GenerateAddressData) AddressPubKey() (string, error)
type TxBuilder ¶
type TxBuilder struct {
Inputs []TxInput
// contains filtered or unexported fields
}
func NewTxBuilder ¶
func (*TxBuilder) CalculateTxSize ¶
func (s *TxBuilder) CalculateTxSize(feePerByte decimal.Decimal) CalculateTxSizeData
CalculateTxSize calculates the size of the transaction and the fee for it.
Docs: https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#transaction-size-calculations
func (*TxBuilder) EmulateTxSize ¶
func (s *TxBuilder) EmulateTxSize(feePerByte decimal.Decimal) (CalculateTxSizeData, error)
EmulateTxSize calculates the size of the transaction and the fee for it.
type WalletSDK ¶
type WalletSDK struct {
// contains filtered or unexported fields
}
func NewWalletSDK ¶
NewWalletSDK creates a new WalletSDK instance.
If chainParams is nil, the mainnet parameters will be used.
func (WalletSDK) AddressFromPrivateKey ¶
func (WalletSDK) ChainParams ¶
ChainParams returns the chain parameters for the wallet
func (WalletSDK) DecodeAddressType ¶
func (s WalletSDK) DecodeAddressType(address string) (AddressType, error)
func (WalletSDK) GenerateAddress ¶
func (s WalletSDK) GenerateAddress(addressType AddressType, mnemonic, passphrase string, sequenceNumber uint32) (*GenerateAddressData, error)