Documentation ¶
Index ¶
- Constants
- Variables
- func ComputeTaprootKeyNoScript(pubkey *btcec.PublicKey) *btcec.PublicKey
- func ComputeTaprootOutputKey(pubKey *btcec.PublicKey, scriptRoot []byte) *btcec.PublicKey
- func TweakTaprootPrivKey(privKey *btcec.PrivateKey, scriptRoot []byte) *btcec.PrivateKey
- func VerifyTaprootLeafCommitment(controlBlock *ControlBlock, taprootWitnessProgram []byte, ...) error
- type ControlBlock
- type IndexedElementsTapScriptTree
- type TapElementsBranch
- type TapElementsLeaf
- type TapscriptElementsProof
Constants ¶
const ( ControlBlockBaseSize = txscript.ControlBlockBaseSize ControlBlockNodeSize = txscript.ControlBlockNodeSize ControlBlockMaxNodeCount = txscript.ControlBlockMaxNodeCount ControlBlockMaxSize = ControlBlockBaseSize + (ControlBlockNodeSize * ControlBlockMaxNodeCount) )
const ( // BaseElementsLeafVersion defines the base leaf version for elements chains // leaf with base leaf version are called "tapscript" // Bitcoin is using 0xc0, Elements is using 0xc4 BaseElementsLeafVersion txscript.TapscriptLeafVersion = 0xc4 )
Variables ¶
var ( TagTapLeafElements = []byte("TapLeaf/elements") TagTapBranchElements = []byte("TapBranch/elements") TagTapSighashElements = []byte("TapSighash/elements") TagTapTweakElements = []byte("TapTweak/elements") )
Functions ¶
func ComputeTaprootKeyNoScript ¶
func ComputeTaprootKeyNoScript(pubkey *btcec.PublicKey) *btcec.PublicKey
func ComputeTaprootOutputKey ¶
func ComputeTaprootOutputKey(pubKey *btcec.PublicKey, scriptRoot []byte) *btcec.PublicKey
ComputeTaprootOutputKey = txscript.ComputeTaprootOutputKey with elements tag
func TweakTaprootPrivKey ¶
func TweakTaprootPrivKey(privKey *btcec.PrivateKey, scriptRoot []byte) *btcec.PrivateKey
TweakTaprootPrivKey = txscript.TweakTaprootPrivKey with elements tag
func VerifyTaprootLeafCommitment ¶
func VerifyTaprootLeafCommitment(controlBlock *ControlBlock, taprootWitnessProgram []byte, revealedScript []byte) error
Types ¶
type ControlBlock ¶
type ControlBlock struct {
txscript.ControlBlock
}
ControlBlock overwrites the RootHash method
func ParseControlBlock ¶
func ParseControlBlock(controlBlock []byte) (*ControlBlock, error)
ParseControlBlock reuses the txscript.ParseControlBlock function but use the elements ControlBlock wrapper struct
func (*ControlBlock) RootHash ¶
func (c *ControlBlock) RootHash(revealedScript []byte) []byte
type IndexedElementsTapScriptTree ¶
type IndexedElementsTapScriptTree struct { RootNode txscript.TapNode LeafMerkleProofs []TapscriptElementsProof LeafProofIndex map[chainhash.Hash]int }
IndexedElementsTapScriptTree reprints a fully contracted tapscript tree. The RootNode can be used to traverse down the full tree. In addition, complete inclusion proofs for each leaf are included as well, with an index into the slice of proof based on the tap leaf hash of a given leaf.
func AssembleTaprootScriptTree ¶
func AssembleTaprootScriptTree(leaves ...TapElementsLeaf) *IndexedElementsTapScriptTree
AssembleTaprootScriptTree constructs a new fully indexed tapscript tree given a series of leaf nodes. A combination of a recursive data structure, and an array-based representation are used to both generate the tree and also accumulate all the necessary inclusion proofs in the same path. See the comment of blockchain.BuildMerkleTreeStore for further details.
func NewIndexedElementsTapScriptTree ¶
func NewIndexedElementsTapScriptTree(numLeaves int) *IndexedElementsTapScriptTree
NewIndexedElementsTapScriptTree creates a new empty tapscript tree that has enough space to hold information for the specified amount of leaves.
type TapElementsBranch ¶
TapElementsBranch implements txscript.TapNode interface
func NewTapElementsBranch ¶
func NewTapElementsBranch(l, r txscript.TapNode) TapElementsBranch
NewTapElementsBranch creates a new branch from two nodes
func (TapElementsBranch) TapHash ¶
func (t TapElementsBranch) TapHash() chainhash.Hash
type TapElementsLeaf ¶
TapElementsLeaf implements txscript.TapNode interface
func NewBaseTapElementsLeaf ¶
func NewBaseTapElementsLeaf(script []byte) TapElementsLeaf
func NewTapElementsLeaf ¶
func NewTapElementsLeaf(leafVersion txscript.TapscriptLeafVersion, script []byte) TapElementsLeaf
NewTapElementsLeaf overwrite the NewTapLeaf constructor
func (TapElementsLeaf) TapHash ¶
func (t TapElementsLeaf) TapHash() chainhash.Hash
TapHash overwrites the txscript.TapLeaf.TapHash method using elements tag
type TapscriptElementsProof ¶
type TapscriptElementsProof struct { TapElementsLeaf RootNode txscript.TapNode InclusionProof []byte }
TapscriptElementsProof overrides the TapscriptProof struct (with elements tapLeaf)
func (*TapscriptElementsProof) ToControlBlock ¶
func (t *TapscriptElementsProof) ToControlBlock(internalKey *btcec.PublicKey) ControlBlock
ToControlBlock maps the tapscript proof into a fully valid control block that can be used as a witness item for a tapscript spend.