mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-10-10 15:03:17 +02:00
lnwallet: add Tree() method, fix formatting
This commit is contained in:
@@ -689,8 +689,8 @@ func (h *HtlcScriptTree) WitnessScriptForPath(path ScriptPath) ([]byte, error) {
|
||||
|
||||
// CtrlBlockForPath returns the control block for the given spending path. For
|
||||
// script types that don't have a control block, nil is returned.
|
||||
func (h *HtlcScriptTree) CtrlBlockForPath(path ScriptPath,
|
||||
) (*txscript.ControlBlock, error) {
|
||||
func (h *HtlcScriptTree) CtrlBlockForPath(
|
||||
path ScriptPath) (*txscript.ControlBlock, error) {
|
||||
|
||||
switch path {
|
||||
case ScriptPathSuccess:
|
||||
@@ -708,6 +708,11 @@ func (h *HtlcScriptTree) CtrlBlockForPath(path ScriptPath,
|
||||
}
|
||||
}
|
||||
|
||||
// Tree returns the underlying ScriptTree of the HtlcScriptTree.
|
||||
func (h *HtlcScriptTree) Tree() ScriptTree {
|
||||
return h.ScriptTree
|
||||
}
|
||||
|
||||
// A compile time check to ensure HtlcScriptTree implements the
|
||||
// TapscriptMultiplexer interface.
|
||||
var _ TapscriptDescriptor = (*HtlcScriptTree)(nil)
|
||||
@@ -1690,9 +1695,9 @@ func TaprootSecondLevelScriptTree(revokeKey, delayKey *btcec.PublicKey,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// WitnessScript returns the witness script that we'll use when signing for the
|
||||
// remote party, and also verifying signatures on our transactions. As an
|
||||
// example, when we create an outgoing HTLC for the remote party, we want to
|
||||
// WitnessScriptToSign returns the witness script that we'll use when signing
|
||||
// for the remote party, and also verifying signatures on our transactions. As
|
||||
// an example, when we create an outgoing HTLC for the remote party, we want to
|
||||
// sign their success path.
|
||||
func (s *SecondLevelScriptTree) WitnessScriptToSign() []byte {
|
||||
return s.SuccessTapLeaf.Script
|
||||
@@ -1700,8 +1705,8 @@ func (s *SecondLevelScriptTree) WitnessScriptToSign() []byte {
|
||||
|
||||
// WitnessScriptForPath returns the witness script for the given spending path.
|
||||
// An error is returned if the path is unknown.
|
||||
func (s *SecondLevelScriptTree) WitnessScriptForPath(path ScriptPath,
|
||||
) ([]byte, error) {
|
||||
func (s *SecondLevelScriptTree) WitnessScriptForPath(
|
||||
path ScriptPath) ([]byte, error) {
|
||||
|
||||
switch path {
|
||||
case ScriptPathDelay:
|
||||
@@ -1716,8 +1721,8 @@ func (s *SecondLevelScriptTree) WitnessScriptForPath(path ScriptPath,
|
||||
|
||||
// CtrlBlockForPath returns the control block for the given spending path. For
|
||||
// script types that don't have a control block, nil is returned.
|
||||
func (s *SecondLevelScriptTree) CtrlBlockForPath(path ScriptPath,
|
||||
) (*txscript.ControlBlock, error) {
|
||||
func (s *SecondLevelScriptTree) CtrlBlockForPath(
|
||||
path ScriptPath) (*txscript.ControlBlock, error) {
|
||||
|
||||
switch path {
|
||||
case ScriptPathDelay:
|
||||
@@ -1733,6 +1738,11 @@ func (s *SecondLevelScriptTree) CtrlBlockForPath(path ScriptPath,
|
||||
}
|
||||
}
|
||||
|
||||
// Tree returns the underlying ScriptTree of the SecondLevelScriptTree.
|
||||
func (s *SecondLevelScriptTree) Tree() ScriptTree {
|
||||
return s.ScriptTree
|
||||
}
|
||||
|
||||
// A compile time check to ensure SecondLevelScriptTree implements the
|
||||
// TapscriptDescriptor interface.
|
||||
var _ TapscriptDescriptor = (*SecondLevelScriptTree)(nil)
|
||||
@@ -2069,9 +2079,9 @@ type CommitScriptTree struct {
|
||||
// TapscriptDescriptor interface.
|
||||
var _ TapscriptDescriptor = (*CommitScriptTree)(nil)
|
||||
|
||||
// WitnessScript returns the witness script that we'll use when signing for the
|
||||
// remote party, and also verifying signatures on our transactions. As an
|
||||
// example, when we create an outgoing HTLC for the remote party, we want to
|
||||
// WitnessScriptToSign returns the witness script that we'll use when signing
|
||||
// for the remote party, and also verifying signatures on our transactions. As
|
||||
// an example, when we create an outgoing HTLC for the remote party, we want to
|
||||
// sign their success path.
|
||||
func (c *CommitScriptTree) WitnessScriptToSign() []byte {
|
||||
// TODO(roasbeef): abstraction leak here? always dependent
|
||||
@@ -2080,8 +2090,8 @@ func (c *CommitScriptTree) WitnessScriptToSign() []byte {
|
||||
|
||||
// WitnessScriptForPath returns the witness script for the given spending path.
|
||||
// An error is returned if the path is unknown.
|
||||
func (c *CommitScriptTree) WitnessScriptForPath(path ScriptPath,
|
||||
) ([]byte, error) {
|
||||
func (c *CommitScriptTree) WitnessScriptForPath(
|
||||
path ScriptPath) ([]byte, error) {
|
||||
|
||||
switch path {
|
||||
// For the commitment output, the delay and success path are the same,
|
||||
@@ -2099,8 +2109,8 @@ func (c *CommitScriptTree) WitnessScriptForPath(path ScriptPath,
|
||||
|
||||
// CtrlBlockForPath returns the control block for the given spending path. For
|
||||
// script types that don't have a control block, nil is returned.
|
||||
func (c *CommitScriptTree) CtrlBlockForPath(path ScriptPath,
|
||||
) (*txscript.ControlBlock, error) {
|
||||
func (c *CommitScriptTree) CtrlBlockForPath(
|
||||
path ScriptPath) (*txscript.ControlBlock, error) {
|
||||
|
||||
switch path {
|
||||
case ScriptPathDelay:
|
||||
@@ -2120,6 +2130,11 @@ func (c *CommitScriptTree) CtrlBlockForPath(path ScriptPath,
|
||||
}
|
||||
}
|
||||
|
||||
// Tree returns the underlying ScriptTree of the CommitScriptTree.
|
||||
func (c *CommitScriptTree) Tree() ScriptTree {
|
||||
return c.ScriptTree
|
||||
}
|
||||
|
||||
// NewLocalCommitScriptTree returns a new CommitScript tree that can be used to
|
||||
// create and spend the commitment output for the local party.
|
||||
func NewLocalCommitScriptTree(csvTimeout uint32,
|
||||
@@ -2241,7 +2256,7 @@ func TaprootCommitScriptToSelf(csvTimeout uint32,
|
||||
return commitScriptTree.TaprootKey, nil
|
||||
}
|
||||
|
||||
// MakeTaprootSCtrlBlock takes a leaf script, the internal key (usually the
|
||||
// MakeTaprootCtrlBlock takes a leaf script, the internal key (usually the
|
||||
// revoke key), and a script tree and creates a valid control block for a spend
|
||||
// of the leaf.
|
||||
func MakeTaprootCtrlBlock(leafScript []byte, internalKey *btcec.PublicKey,
|
||||
@@ -2296,9 +2311,6 @@ func TaprootCommitSpendSuccess(signer Signer, signDesc *SignDescriptor,
|
||||
witnessStack[0] = maybeAppendSighash(sweepSig, signDesc.HashType)
|
||||
witnessStack[1] = signDesc.WitnessScript
|
||||
witnessStack[2] = ctrlBlockBytes
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return witnessStack, nil
|
||||
}
|
||||
@@ -2773,8 +2785,8 @@ type AnchorScriptTree struct {
|
||||
|
||||
// NewAnchorScriptTree makes a new script tree for an anchor output with the
|
||||
// passed anchor key.
|
||||
func NewAnchorScriptTree(anchorKey *btcec.PublicKey,
|
||||
) (*AnchorScriptTree, error) {
|
||||
func NewAnchorScriptTree(
|
||||
anchorKey *btcec.PublicKey) (*AnchorScriptTree, error) {
|
||||
|
||||
// The main script used is just a OP_16 CSV (anyone can sweep after 16
|
||||
// blocks).
|
||||
@@ -2810,9 +2822,9 @@ func NewAnchorScriptTree(anchorKey *btcec.PublicKey,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// WitnessScript returns the witness script that we'll use when signing for the
|
||||
// remote party, and also verifying signatures on our transactions. As an
|
||||
// example, when we create an outgoing HTLC for the remote party, we want to
|
||||
// WitnessScriptToSign returns the witness script that we'll use when signing
|
||||
// for the remote party, and also verifying signatures on our transactions. As
|
||||
// an example, when we create an outgoing HTLC for the remote party, we want to
|
||||
// sign their success path.
|
||||
func (a *AnchorScriptTree) WitnessScriptToSign() []byte {
|
||||
return a.SweepLeaf.Script
|
||||
@@ -2820,8 +2832,8 @@ func (a *AnchorScriptTree) WitnessScriptToSign() []byte {
|
||||
|
||||
// WitnessScriptForPath returns the witness script for the given spending path.
|
||||
// An error is returned if the path is unknown.
|
||||
func (a *AnchorScriptTree) WitnessScriptForPath(path ScriptPath,
|
||||
) ([]byte, error) {
|
||||
func (a *AnchorScriptTree) WitnessScriptForPath(
|
||||
path ScriptPath) ([]byte, error) {
|
||||
|
||||
switch path {
|
||||
case ScriptPathDelay:
|
||||
@@ -2836,8 +2848,8 @@ func (a *AnchorScriptTree) WitnessScriptForPath(path ScriptPath,
|
||||
|
||||
// CtrlBlockForPath returns the control block for the given spending path. For
|
||||
// script types that don't have a control block, nil is returned.
|
||||
func (a *AnchorScriptTree) CtrlBlockForPath(path ScriptPath,
|
||||
) (*txscript.ControlBlock, error) {
|
||||
func (a *AnchorScriptTree) CtrlBlockForPath(
|
||||
path ScriptPath) (*txscript.ControlBlock, error) {
|
||||
|
||||
switch path {
|
||||
case ScriptPathDelay:
|
||||
@@ -2853,6 +2865,11 @@ func (a *AnchorScriptTree) CtrlBlockForPath(path ScriptPath,
|
||||
}
|
||||
}
|
||||
|
||||
// Tree returns the underlying ScriptTree of the AnchorScriptTree.
|
||||
func (a *AnchorScriptTree) Tree() ScriptTree {
|
||||
return a.ScriptTree
|
||||
}
|
||||
|
||||
// A compile time check to ensure AnchorScriptTree implements the
|
||||
// TapscriptDescriptor interface.
|
||||
var _ TapscriptDescriptor = (*AnchorScriptTree)(nil)
|
||||
|
Reference in New Issue
Block a user