Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeriveAddress ¶
func DeriveAddress( extendedPublicKey string, addressIndex uint32, chainParams *chaincfg.Params, ) (string, error)
DeriveAddress uses the specified extended public key and address index to derive an address string in the appropriate format at the specified address index. The extended public key can be at any level. deriveAddress will take the first child `/0` until a depth of 4 is reached, and then produce the address at the supplied index. Thus, calling deriveAddress with an xpub generated at m/44'/0' and passing the address index 5 will produce the address at path m/44'/0'/0/0/5.
In cases where the extended public key is at depth 4, meaning the external or internal chain is already included, deriveAddress will directly derive the address index at the existing depth.
deriveAddress does not support hardened child indexes (anything greater than or equal to 2147483648, abbreviated as 0')
The returned address will be a p2pkh/p2sh address for prefixes xpub and tpub, (i.e. prefixed by 1, m, or n), a p2wpkh-in-p2sh address for prefixes ypub or upub (i.e., prefixed by 3 or 2), and a bech32 p2wpkh address for prefixes zpub or vpub (i.e., prefixed by bc1 or tb1).
See BIP32, BIP44, BIP49, and BIP84 for more on address derivation, particular paths, etc.
func ValidateAddress ¶
ValidateAddress checks to see if the btc address is valid on the supplied chain. It is expected that final bitcoin address is provided, *pub extended key will fail the validation.
Types ¶
type Config ¶
type Config struct { BeneficiaryAddress string MaxFeePerVByte int32 BitcoinChainName string ElectrsURL *string }
Config stores configuration related to recovering BTC from a closed keep.
func (Config) ChainParams ¶
ChainParams parses the net param name into the associated chaincfg.Params
func (Config) ElectrsURLWithDefault ¶
ElectrsURLWithDefault dereferences ElectrsURL in the following way: if there is a configured value, use it. Otherwise, default to https://blockstream.info/api/. This allows us to add bitcoin connection functionality to nodes that haven't made config changes yet while also letting a user connect to the node of their choice.