Documentation ¶
Index ¶
- Variables
- func Hash160(buf []byte) []byte
- type Payment
- func FromPayment(payment *Payment) (*Payment, error)
- func FromPublicKey(pubkey *btcec.PublicKey, net *network.Network, blindingKey *btcec.PublicKey) *Payment
- func FromPublicKeys(pubkeys []*btcec.PublicKey, nrequired int, net *network.Network, ...) (*Payment, error)
- func FromScript(outputScript []byte, net *network.Network, blindingKey *btcec.PublicKey) (*Payment, error)
- func FromTaprootScriptTree(internalKey *btcec.PublicKey, tree *taproot.IndexedElementsTapScriptTree, ...) (*Payment, error)
- func FromTaprootScriptTreeHash(internalKey *btcec.PublicKey, rootHash *chainhash.Hash, net *network.Network, ...) (*Payment, error)
- func FromTweakedKey(tweakedKey *btcec.PublicKey, net *network.Network, ...) (*Payment, error)
- func (p *Payment) ConfidentialPubKeyHash() (string, error)
- func (p *Payment) ConfidentialScriptHash() (string, error)
- func (p *Payment) ConfidentialTaprootAddress() (string, error)
- func (p *Payment) ConfidentialWitnessPubKeyHash() (string, error)
- func (p *Payment) ConfidentialWitnessScriptHash() (string, error)
- func (p *Payment) PubKeyHash() (string, error)
- func (p *Payment) ScriptHash() (string, error)
- func (p *Payment) TaprootAddress() (string, error)
- func (p *Payment) WitnessPubKeyHash() (string, error)
- func (p *Payment) WitnessScriptHash() (string, error)
- type TaprootPaymentData
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrTaprootDataIsNil = errors.New("taproot payment data is required to derive taproot addresses") ErrNetworkIsNil = errors.New("network is required to derive taproot addresses") )
Functions ¶
Types ¶
type Payment ¶
type Payment struct { Hash []byte WitnessHash []byte Script []byte WitnessScript []byte Redeem *Payment PublicKey *btcec.PublicKey BlindingKey *btcec.PublicKey Network *network.Network Taproot *TaprootPaymentData }
Payment defines the structure that holds the information different addresses
func FromPayment ¶
FromPayment creates a Payment struct from a another Payment
Example ¶
This examples shows how nested payment can be done in order to create non native SegWit(P2SH-P2WPKH) address
_, publicKey := btcec.PrivKeyFromBytes(privateKeyBytes) p2wpkh := payment.FromPublicKey(publicKey, &network.Regtest, nil) pay, err := payment.FromPayment(p2wpkh) p2sh, err := pay.ScriptHash() if err != nil { fmt.Println(err) } fmt.Printf("Non native SegWit address %v\n:", p2sh)
Output:
func FromPublicKey ¶
func FromPublicKey( pubkey *btcec.PublicKey, net *network.Network, blindingKey *btcec.PublicKey, ) *Payment
FromPublicKey creates a Payment struct from a btcec.publicKey
Example ¶
This examples shows how standard P2PKH address can be created
_, publicKey := btcec.PrivKeyFromBytes(privateKeyBytes) pay := payment.FromPublicKey(publicKey, &network.Regtest, nil) addr, _ := pay.PubKeyHash() fmt.Printf("P2PKH address %v\n:", addr)
Output:
func FromPublicKeys ¶
func FromPublicKeys( pubkeys []*btcec.PublicKey, nrequired int, net *network.Network, blindingKey *btcec.PublicKey, ) (*Payment, error)
FromPublicKeys creates a multi-signature Payment struct from list of public key's
func FromScript ¶
func FromScript( outputScript []byte, net *network.Network, blindingKey *btcec.PublicKey, ) (*Payment, error)
FromScript creates parses a script into a Payment struct
func FromTaprootScriptTree ¶ added in v0.4.0
func FromTaprootScriptTree( internalKey *btcec.PublicKey, tree *taproot.IndexedElementsTapScriptTree, net *network.Network, blindingKey *btcec.PublicKey, ) (*Payment, error)
FromTaprootScriptTree creates a taproot payment from a merkle script tree and internal key
func FromTaprootScriptTreeHash ¶ added in v0.4.0
func FromTaprootScriptTreeHash( internalKey *btcec.PublicKey, rootHash *chainhash.Hash, net *network.Network, blindingKey *btcec.PublicKey, ) (*Payment, error)
FromTaprootScriptTreeHash creates a taproot payment from a merkle script tree hash and internal key
func FromTweakedKey ¶ added in v0.4.0
func FromTweakedKey( tweakedKey *btcec.PublicKey, net *network.Network, blindingKey *btcec.PublicKey, ) (*Payment, error)
FromTweakedKey creates a P2TR payment from a tweaked output key
func (*Payment) ConfidentialPubKeyHash ¶ added in v0.0.2
ConfidentialPubKeyHash is a method of the Payment struct to derive a base58 confidential p2pkh address
func (*Payment) ConfidentialScriptHash ¶ added in v0.0.2
ConfidentialScriptHash is a method of the Payment struct to derive a base58 confidential p2sh address
func (*Payment) ConfidentialTaprootAddress ¶ added in v0.4.0
ConfidentialTaprootAddress derives a confidential segwit v1 address from the payment taproot data
func (*Payment) ConfidentialWitnessPubKeyHash ¶ added in v0.0.2
ConfidentialWitnessPubKeyHash is a method of the Payment struct to derive a confidential blech32 p2wpkh address
func (*Payment) ConfidentialWitnessScriptHash ¶ added in v0.0.2
ConfidentialWitnessScriptHash is a method of the Payment struct to derive a confidential blech32 p2wsh address
func (*Payment) PubKeyHash ¶
PubKeyHash is a method of the Payment struct to derive a base58 p2pkh address
func (*Payment) ScriptHash ¶
ScriptHash is a method of the Payment struct to derive a base58 p2sh address
func (*Payment) TaprootAddress ¶ added in v0.4.0
TaprootAddress derives the unconditional Taproot address from the payment data
func (*Payment) WitnessPubKeyHash ¶
WitnessPubKeyHash is a method of the Payment struct to derive a base58 p2wpkh address
func (*Payment) WitnessScriptHash ¶
WitnessScriptHash is a method of the Payment struct to derive a base58 p2wsh address
type TaprootPaymentData ¶ added in v0.4.0
type TaprootPaymentData struct { XOnlyTweakedKey []byte XOnlyInternalKey []byte RootScriptTreeHash *chainhash.Hash ScriptTree *taproot.IndexedElementsTapScriptTree }
TaprootPaymentData is included in Payment struct to store Taproot-related data