multi: fix linter errors
This commit is contained in:
20 files changed
+185
-142
No files matched your search
@@ -565,8 +565,8 @@ func convertToSecondLevelRevoke(bo *breachedOutput, breachInfo *retributionInfo,
|
|||||||
bo.signDesc.Output.PkScript = spendingTx.TxOut[spendInputIndex].PkScript
|
bo.signDesc.Output.PkScript = spendingTx.TxOut[spendInputIndex].PkScript
|
||||||
|
|
||||||
// For taproot outputs, the taptweak also needs to be swapped out. We
|
// For taproot outputs, the taptweak also needs to be swapped out. We
|
||||||
// do this unconditionaly as this field isn't used at all for segwit v0
|
// do this unconditionally as this field isn't used at all for segwit
|
||||||
// outputs.
|
// v0 outputs.
|
||||||
bo.signDesc.TapTweak = bo.secondLevelTapTweak[:]
|
bo.signDesc.TapTweak = bo.secondLevelTapTweak[:]
|
||||||
|
|
||||||
// Finally, we'll need to adjust the witness program in the
|
// Finally, we'll need to adjust the witness program in the
|
||||||
@@ -1234,7 +1234,9 @@ func newRetributionInfo(chanPoint *wire.OutPoint,
|
|||||||
case isTaproot:
|
case isTaproot:
|
||||||
witnessType = input.TaprootRemoteCommitSpend
|
witnessType = input.TaprootRemoteCommitSpend
|
||||||
|
|
||||||
case !isTaproot && breachInfo.LocalOutputSignDesc.SingleTweak == nil:
|
case !isTaproot &&
|
||||||
|
breachInfo.LocalOutputSignDesc.SingleTweak == nil:
|
||||||
|
|
||||||
witnessType = input.CommitSpendNoDelayTweakless
|
witnessType = input.CommitSpendNoDelayTweakless
|
||||||
|
|
||||||
case !isTaproot:
|
case !isTaproot:
|
||||||
@@ -1296,7 +1298,6 @@ func newRetributionInfo(chanPoint *wire.OutPoint,
|
|||||||
// to sweep the HTLC output.
|
// to sweep the HTLC output.
|
||||||
var htlcWitnessType input.StandardWitnessType
|
var htlcWitnessType input.StandardWitnessType
|
||||||
switch {
|
switch {
|
||||||
|
|
||||||
case isTaproot && breachedHtlc.IsIncoming:
|
case isTaproot && breachedHtlc.IsIncoming:
|
||||||
htlcWitnessType = input.TaprootHtlcAcceptedRevoke
|
htlcWitnessType = input.TaprootHtlcAcceptedRevoke
|
||||||
|
|
||||||
@@ -1652,7 +1653,9 @@ func taprootBriefcaseFromRetInfo(retInfo *retributionInfo) *taprootBriefcase {
|
|||||||
|
|
||||||
// applyTaprootRetInfo attaches the taproot specific inforamtion in the tapCase
|
// applyTaprootRetInfo attaches the taproot specific inforamtion in the tapCase
|
||||||
// to the passed retInfo struct.
|
// to the passed retInfo struct.
|
||||||
func applyTaprootRetInfo(tapCase *taprootBriefcase, retInfo *retributionInfo) error {
|
func applyTaprootRetInfo(tapCase *taprootBriefcase,
|
||||||
|
retInfo *retributionInfo) error {
|
||||||
|
|
||||||
for i := range retInfo.breachedOutputs {
|
for i := range retInfo.breachedOutputs {
|
||||||
bo := retInfo.breachedOutputs[i]
|
bo := retInfo.breachedOutputs[i]
|
||||||
|
|
||||||
@@ -1725,7 +1728,8 @@ func (rs *RetributionStore) Add(ret *retributionInfo) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if retBucket.Put(outBuf.Bytes(), retBuf.Bytes()); err != nil {
|
err = retBucket.Put(outBuf.Bytes(), retBuf.Bytes())
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1552,6 +1552,7 @@ func encodeTaprootAuxData(w io.Writer, c *ContractResolutions) error {
|
|||||||
if c.CommitResolution != nil {
|
if c.CommitResolution != nil {
|
||||||
commitResolution := c.CommitResolution
|
commitResolution := c.CommitResolution
|
||||||
commitSignDesc := commitResolution.SelfOutputSignDesc
|
commitSignDesc := commitResolution.SelfOutputSignDesc
|
||||||
|
//nolint:lll
|
||||||
tapCase.CtrlBlocks.CommitSweepCtrlBlock = commitSignDesc.ControlBlock
|
tapCase.CtrlBlocks.CommitSweepCtrlBlock = commitSignDesc.ControlBlock
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1569,7 +1570,6 @@ func encodeTaprootAuxData(w io.Writer, c *ContractResolutions) error {
|
|||||||
resID := newResolverID(
|
resID := newResolverID(
|
||||||
htlc.SignedSuccessTx.TxIn[0].PreviousOutPoint,
|
htlc.SignedSuccessTx.TxIn[0].PreviousOutPoint,
|
||||||
)
|
)
|
||||||
|
|
||||||
//nolint:lll
|
//nolint:lll
|
||||||
tapCase.CtrlBlocks.SecondLevelCtrlBlocks[resID] = ctrlBlock
|
tapCase.CtrlBlocks.SecondLevelCtrlBlocks[resID] = ctrlBlock
|
||||||
|
|
||||||
@@ -1584,6 +1584,7 @@ func encodeTaprootAuxData(w io.Writer, c *ContractResolutions) error {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
resID := newResolverID(htlc.ClaimOutpoint)
|
resID := newResolverID(htlc.ClaimOutpoint)
|
||||||
|
//nolint:lll
|
||||||
tapCase.CtrlBlocks.IncomingHtlcCtrlBlocks[resID] = ctrlBlock
|
tapCase.CtrlBlocks.IncomingHtlcCtrlBlocks[resID] = ctrlBlock
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1601,7 +1602,6 @@ func encodeTaprootAuxData(w io.Writer, c *ContractResolutions) error {
|
|||||||
resID := newResolverID(
|
resID := newResolverID(
|
||||||
htlc.SignedTimeoutTx.TxIn[0].PreviousOutPoint,
|
htlc.SignedTimeoutTx.TxIn[0].PreviousOutPoint,
|
||||||
)
|
)
|
||||||
|
|
||||||
//nolint:lll
|
//nolint:lll
|
||||||
tapCase.CtrlBlocks.SecondLevelCtrlBlocks[resID] = ctrlBlock
|
tapCase.CtrlBlocks.SecondLevelCtrlBlocks[resID] = ctrlBlock
|
||||||
|
|
||||||
@@ -1618,9 +1618,9 @@ func encodeTaprootAuxData(w io.Writer, c *ContractResolutions) error {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
resID := newResolverID(htlc.ClaimOutpoint)
|
resID := newResolverID(htlc.ClaimOutpoint)
|
||||||
|
//nolint:lll
|
||||||
tapCase.CtrlBlocks.OutgoingHtlcCtrlBlocks[resID] = ctrlBlock
|
tapCase.CtrlBlocks.OutgoingHtlcCtrlBlocks[resID] = ctrlBlock
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.AnchorResolution != nil {
|
if c.AnchorResolution != nil {
|
||||||
@@ -1651,6 +1651,7 @@ func decodeTapRootAuxData(r io.Reader, c *ContractResolutions) error {
|
|||||||
htlc.SignedSuccessTx.TxIn[0].PreviousOutPoint,
|
htlc.SignedSuccessTx.TxIn[0].PreviousOutPoint,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//nolint:lll
|
||||||
ctrlBlock := tapCase.CtrlBlocks.SecondLevelCtrlBlocks[resID]
|
ctrlBlock := tapCase.CtrlBlocks.SecondLevelCtrlBlocks[resID]
|
||||||
htlc.SweepSignDesc.ControlBlock = ctrlBlock
|
htlc.SweepSignDesc.ControlBlock = ctrlBlock
|
||||||
|
|
||||||
@@ -1662,6 +1663,7 @@ func decodeTapRootAuxData(r io.Reader, c *ContractResolutions) error {
|
|||||||
} else {
|
} else {
|
||||||
resID = newResolverID(htlc.ClaimOutpoint)
|
resID = newResolverID(htlc.ClaimOutpoint)
|
||||||
|
|
||||||
|
//nolint:lll
|
||||||
ctrlBlock := tapCase.CtrlBlocks.IncomingHtlcCtrlBlocks[resID]
|
ctrlBlock := tapCase.CtrlBlocks.IncomingHtlcCtrlBlocks[resID]
|
||||||
htlc.SweepSignDesc.ControlBlock = ctrlBlock
|
htlc.SweepSignDesc.ControlBlock = ctrlBlock
|
||||||
}
|
}
|
||||||
@@ -1677,6 +1679,7 @@ func decodeTapRootAuxData(r io.Reader, c *ContractResolutions) error {
|
|||||||
htlc.SignedTimeoutTx.TxIn[0].PreviousOutPoint,
|
htlc.SignedTimeoutTx.TxIn[0].PreviousOutPoint,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//nolint:lll
|
||||||
ctrlBlock := tapCase.CtrlBlocks.SecondLevelCtrlBlocks[resID]
|
ctrlBlock := tapCase.CtrlBlocks.SecondLevelCtrlBlocks[resID]
|
||||||
htlc.SweepSignDesc.ControlBlock = ctrlBlock
|
htlc.SweepSignDesc.ControlBlock = ctrlBlock
|
||||||
|
|
||||||
@@ -1688,6 +1691,7 @@ func decodeTapRootAuxData(r io.Reader, c *ContractResolutions) error {
|
|||||||
} else {
|
} else {
|
||||||
resID = newResolverID(htlc.ClaimOutpoint)
|
resID = newResolverID(htlc.ClaimOutpoint)
|
||||||
|
|
||||||
|
//nolint:lll
|
||||||
ctrlBlock := tapCase.CtrlBlocks.OutgoingHtlcCtrlBlocks[resID]
|
ctrlBlock := tapCase.CtrlBlocks.OutgoingHtlcCtrlBlocks[resID]
|
||||||
htlc.SweepSignDesc.ControlBlock = ctrlBlock
|
htlc.SweepSignDesc.ControlBlock = ctrlBlock
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -283,7 +283,7 @@ func (c *commitSweepResolver) Resolve() (ContractResolver, error) {
|
|||||||
// remote key (us in this case), those that don't, and a third where
|
// remote key (us in this case), those that don't, and a third where
|
||||||
// there is no tweak and the output is delayed. On the local commitment
|
// there is no tweak and the output is delayed. On the local commitment
|
||||||
// our output will always be delayed. We'll rely on the presence of the
|
// our output will always be delayed. We'll rely on the presence of the
|
||||||
// commitment tweak to to discern which type of commitment this is.
|
// commitment tweak to discern which type of commitment this is.
|
||||||
var witnessType input.WitnessType
|
var witnessType input.WitnessType
|
||||||
switch {
|
switch {
|
||||||
// The local delayed output for a taproot channel.
|
// The local delayed output for a taproot channel.
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ func (h *htlcIncomingContestResolver) Resolve() (ContractResolver, error) {
|
|||||||
// If this is our commitment transaction, then we'll need to
|
// If this is our commitment transaction, then we'll need to
|
||||||
// populate the witness for the second-level HTLC transaction.
|
// populate the witness for the second-level HTLC transaction.
|
||||||
switch {
|
switch {
|
||||||
// For taproot channels, the witness for sweeping with sucess
|
// For taproot channels, the witness for sweeping with success
|
||||||
// looks like:
|
// looks like:
|
||||||
// - <sender sig> <receiver sig> <preimage> <success_script>
|
// - <sender sig> <receiver sig> <preimage> <success_script>
|
||||||
// <control_block>
|
// <control_block>
|
||||||
|
|||||||
@@ -245,12 +245,14 @@ func (h *htlcSuccessResolver) broadcastReSignedSuccessTx() (
|
|||||||
|
|
||||||
var secondLevelInput input.HtlcSecondLevelAnchorInput
|
var secondLevelInput input.HtlcSecondLevelAnchorInput
|
||||||
if isTaproot {
|
if isTaproot {
|
||||||
|
//nolint:lll
|
||||||
secondLevelInput = input.MakeHtlcSecondLevelSuccessTaprootInput(
|
secondLevelInput = input.MakeHtlcSecondLevelSuccessTaprootInput(
|
||||||
h.htlcResolution.SignedSuccessTx,
|
h.htlcResolution.SignedSuccessTx,
|
||||||
h.htlcResolution.SignDetails, h.htlcResolution.Preimage,
|
h.htlcResolution.SignDetails, h.htlcResolution.Preimage,
|
||||||
h.broadcastHeight,
|
h.broadcastHeight,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
//nolint:lll
|
||||||
secondLevelInput = input.MakeHtlcSecondLevelSuccessAnchorInput(
|
secondLevelInput = input.MakeHtlcSecondLevelSuccessAnchorInput(
|
||||||
h.htlcResolution.SignedSuccessTx,
|
h.htlcResolution.SignedSuccessTx,
|
||||||
h.htlcResolution.SignDetails, h.htlcResolution.Preimage,
|
h.htlcResolution.SignDetails, h.htlcResolution.Preimage,
|
||||||
|
|||||||
@@ -161,6 +161,7 @@ func (h *htlcTimeoutResolver) claimCleanUp(
|
|||||||
// - <sender sig> <receiver sig> <preimage> <success_script>
|
// - <sender sig> <receiver sig> <preimage> <success_script>
|
||||||
// <control_block>
|
// <control_block>
|
||||||
case h.isTaproot() && h.htlcResolution.SignedTimeoutTx == nil:
|
case h.isTaproot() && h.htlcResolution.SignedTimeoutTx == nil:
|
||||||
|
//nolint:lll
|
||||||
preimageBytes = spendingInput.Witness[taprootRemotePreimageIndex]
|
preimageBytes = spendingInput.Witness[taprootRemotePreimageIndex]
|
||||||
|
|
||||||
// The witness stack when the remote party sweeps the output on a
|
// The witness stack when the remote party sweeps the output on a
|
||||||
@@ -174,7 +175,7 @@ func (h *htlcTimeoutResolver) claimCleanUp(
|
|||||||
// element, then we're actually on the losing side of a breach
|
// element, then we're actually on the losing side of a breach
|
||||||
// attempt...
|
// attempt...
|
||||||
case h.isTaproot() && len(spendingInput.Witness) == 1:
|
case h.isTaproot() && len(spendingInput.Witness) == 1:
|
||||||
return nil, fmt.Errorf("breach attempt failed...")
|
return nil, fmt.Errorf("breach attempt failed")
|
||||||
|
|
||||||
// Otherwise, they'll be spending directly from our commitment output.
|
// Otherwise, they'll be spending directly from our commitment output.
|
||||||
// In which case the witness stack looks like:
|
// In which case the witness stack looks like:
|
||||||
@@ -250,6 +251,8 @@ func (h *htlcTimeoutResolver) chainDetailsToWatch() (*wire.OutPoint, []byte, err
|
|||||||
// points to. We can directly grab the outpoint, then also extract the
|
// points to. We can directly grab the outpoint, then also extract the
|
||||||
// witness script (the last element of the witness stack) to
|
// witness script (the last element of the witness stack) to
|
||||||
// re-construct the pkScript we need to watch.
|
// re-construct the pkScript we need to watch.
|
||||||
|
//
|
||||||
|
//nolint:lll
|
||||||
outPointToWatch := h.htlcResolution.SignedTimeoutTx.TxIn[0].PreviousOutPoint
|
outPointToWatch := h.htlcResolution.SignedTimeoutTx.TxIn[0].PreviousOutPoint
|
||||||
witness := h.htlcResolution.SignedTimeoutTx.TxIn[0].Witness
|
witness := h.htlcResolution.SignedTimeoutTx.TxIn[0].Witness
|
||||||
|
|
||||||
@@ -263,7 +266,8 @@ func (h *htlcTimeoutResolver) chainDetailsToWatch() (*wire.OutPoint, []byte, err
|
|||||||
// these together to reconstruct the taproot output key, then map that
|
// these together to reconstruct the taproot output key, then map that
|
||||||
// into a v1 witness program.
|
// into a v1 witness program.
|
||||||
case h.isTaproot():
|
case h.isTaproot():
|
||||||
// First, we'll parse the control block into something we can use.
|
// First, we'll parse the control block into something we can
|
||||||
|
// use.
|
||||||
ctrlBlockBytes := witness[len(witness)-1]
|
ctrlBlockBytes := witness[len(witness)-1]
|
||||||
ctrlBlock, err := txscript.ParseControlBlock(ctrlBlockBytes)
|
ctrlBlock, err := txscript.ParseControlBlock(ctrlBlockBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -282,6 +286,9 @@ func (h *htlcTimeoutResolver) chainDetailsToWatch() (*wire.OutPoint, []byte, err
|
|||||||
ctrlBlock.InternalKey, tapscriptRoot,
|
ctrlBlock.InternalKey, tapscriptRoot,
|
||||||
)
|
)
|
||||||
scriptToWatch, err = txscript.PayToTaprootScript(outputKey)
|
scriptToWatch, err = txscript.PayToTaprootScript(outputKey)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
// For regular channels, the witness script is the last element on the
|
// For regular channels, the witness script is the last element on the
|
||||||
// stack. We can then use this to re-derive the output that we're
|
// stack. We can then use this to re-derive the output that we're
|
||||||
@@ -323,6 +330,7 @@ func isPreimageSpend(isTaproot bool, spend *chainntnfs.SpendDetail,
|
|||||||
// <control_block>
|
// <control_block>
|
||||||
case isTaproot && !localCommit:
|
case isTaproot && !localCommit:
|
||||||
preImageIdx := taprootRemotePreimageIndex
|
preImageIdx := taprootRemotePreimageIndex
|
||||||
|
//nolint:lll
|
||||||
return len(spendingWitness) == remoteTaprootWitnessSuccessSize &&
|
return len(spendingWitness) == remoteTaprootWitnessSuccessSize &&
|
||||||
len(spendingWitness[preImageIdx]) == lntypes.HashSize
|
len(spendingWitness[preImageIdx]) == lntypes.HashSize
|
||||||
|
|
||||||
@@ -335,7 +343,8 @@ func isPreimageSpend(isTaproot bool, spend *chainntnfs.SpendDetail,
|
|||||||
//
|
//
|
||||||
// - <receiver sig> <preimage> <success_script> <control_block>
|
// - <receiver sig> <preimage> <success_script> <control_block>
|
||||||
case isTaproot && localCommit:
|
case isTaproot && localCommit:
|
||||||
return len(spendingWitness[localPreimageIndex]) == lntypes.HashSize
|
return len(spendingWitness[localPreimageIndex]) ==
|
||||||
|
lntypes.HashSize
|
||||||
|
|
||||||
// If this is the non-taproot, remote commitment then the only possible
|
// If this is the non-taproot, remote commitment then the only possible
|
||||||
// spends for outgoing HTLCs are:
|
// spends for outgoing HTLCs are:
|
||||||
@@ -350,7 +359,8 @@ func isPreimageSpend(isTaproot bool, spend *chainntnfs.SpendDetail,
|
|||||||
// revoked their output.
|
// revoked their output.
|
||||||
case !isTaproot && !localCommit:
|
case !isTaproot && !localCommit:
|
||||||
return len(spendingWitness) == expectedRemoteWitnessSuccessSize &&
|
return len(spendingWitness) == expectedRemoteWitnessSuccessSize &&
|
||||||
len(spendingWitness[remotePreimageIndex]) == lntypes.HashSize
|
len(spendingWitness[remotePreimageIndex]) ==
|
||||||
|
lntypes.HashSize
|
||||||
|
|
||||||
// Otherwise, for our non-taproot commitment, the only possible spends
|
// Otherwise, for our non-taproot commitment, the only possible spends
|
||||||
// for an outgoing HTLC are:
|
// for an outgoing HTLC are:
|
||||||
@@ -364,7 +374,8 @@ func isPreimageSpend(isTaproot bool, spend *chainntnfs.SpendDetail,
|
|||||||
case !isTaproot:
|
case !isTaproot:
|
||||||
fallthrough
|
fallthrough
|
||||||
default:
|
default:
|
||||||
return len(spendingWitness[localPreimageIndex]) == lntypes.HashSize
|
return len(spendingWitness[localPreimageIndex]) ==
|
||||||
|
lntypes.HashSize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,48 +22,6 @@ const (
|
|||||||
secondLevelHtlcTweakCtrlBlockType tlv.Type = 2
|
secondLevelHtlcTweakCtrlBlockType tlv.Type = 2
|
||||||
)
|
)
|
||||||
|
|
||||||
// tlvDecoder is an interface to support more generic decoding of TLV records.
|
|
||||||
type tlvDecoder interface {
|
|
||||||
// DecodeRecords returns a slice of TLV records that should be decoded.
|
|
||||||
DecodeRecords() []tlv.Record
|
|
||||||
|
|
||||||
// Decode decodes the given reader into the target struct.
|
|
||||||
Decode(r io.Reader) error
|
|
||||||
}
|
|
||||||
|
|
||||||
// makeAndDecodeStream takes a tlvDecoder and decodes the records encoded in
|
|
||||||
// the stream into it.
|
|
||||||
//
|
|
||||||
// TODO(roasbeef): use elsewhere
|
|
||||||
func makeAndDecodeStream(r io.Reader, d tlvDecoder) error {
|
|
||||||
stream, err := tlv.NewStream(d.DecodeRecords()...)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return stream.Decode(r)
|
|
||||||
}
|
|
||||||
|
|
||||||
// tlvEncoder is an interface to support more generic encoding of TLV records.
|
|
||||||
type tlvEncoder interface {
|
|
||||||
// EncodeRecords returns a slice of TLV records that should be encoded.
|
|
||||||
EncodeRecords() []tlv.Record
|
|
||||||
|
|
||||||
// Encode encodes the target struct into the given writer.
|
|
||||||
Encode(w io.Writer) error
|
|
||||||
}
|
|
||||||
|
|
||||||
// makeAnEncodeStream takes a tlvEncoder and encodes the records into the
|
|
||||||
// target writer as a TLV stream.
|
|
||||||
func makeAndEncodeStream[E tlvEncoder](w io.Writer, e E) error {
|
|
||||||
stream, err := tlv.NewStream(e.EncodeRecords()...)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return stream.Encode(w)
|
|
||||||
}
|
|
||||||
|
|
||||||
// taprootBriefcase is a supplemental storage struct that contains all the
|
// taprootBriefcase is a supplemental storage struct that contains all the
|
||||||
// information we need to sweep taproot outputs.
|
// information we need to sweep taproot outputs.
|
||||||
type taprootBriefcase struct {
|
type taprootBriefcase struct {
|
||||||
@@ -107,6 +65,7 @@ func (t *taprootBriefcase) Encode(w io.Writer) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return stream.Encode(w)
|
return stream.Encode(w)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,13 +75,15 @@ func (t *taprootBriefcase) Decode(r io.Reader) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return stream.Decode(r)
|
return stream.Decode(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
// resolverCtrlBlocks is a map of resolver IDs to their corresponding control block.
|
// resolverCtrlBlocks is a map of resolver IDs to their corresponding control
|
||||||
|
// block.
|
||||||
type resolverCtrlBlocks map[resolverID][]byte
|
type resolverCtrlBlocks map[resolverID][]byte
|
||||||
|
|
||||||
// newResolverCtrlBlockss returns a new instance of the resolverCtrlBlocks
|
// newResolverCtrlBlockss returns a new instance of the resolverCtrlBlocks.
|
||||||
func newResolverCtrlBlocks() resolverCtrlBlocks {
|
func newResolverCtrlBlocks() resolverCtrlBlocks {
|
||||||
return make(resolverCtrlBlocks)
|
return make(resolverCtrlBlocks)
|
||||||
}
|
}
|
||||||
@@ -170,32 +131,34 @@ func (r *resolverCtrlBlocks) Encode(w io.Writer) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Decode decodes the given reader into the target struct.
|
// Decode decodes the given reader into the target struct.
|
||||||
func (t *resolverCtrlBlocks) Decode(r io.Reader) error {
|
func (r *resolverCtrlBlocks) Decode(reader io.Reader) error {
|
||||||
var buf [8]byte
|
var buf [8]byte
|
||||||
|
|
||||||
numBlocks, err := tlv.ReadVarInt(r, &buf)
|
numBlocks, err := tlv.ReadVarInt(reader, &buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := uint64(0); i < numBlocks; i++ {
|
for i := uint64(0); i < numBlocks; i++ {
|
||||||
var id resolverID
|
var id resolverID
|
||||||
if _, err := io.ReadFull(r, id[:]); err != nil {
|
if _, err := io.ReadFull(reader, id[:]); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var ctrlBlock []byte
|
var ctrlBlock []byte
|
||||||
if err := varBytesDecoder(r, &ctrlBlock, &buf, 0); err != nil {
|
err := varBytesDecoder(reader, &ctrlBlock, &buf, 0)
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
(*t)[id] = ctrlBlock
|
(*r)[id] = ctrlBlock
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// resolverCtrlBlocksEncoder is a custom TLV encoder for the resolverCtrlBlocks
|
// resolverCtrlBlocksEncoder is a custom TLV encoder for the
|
||||||
|
// resolverCtrlBlocks.
|
||||||
func resolverCtrlBlocksEncoder(w io.Writer, val any, buf *[8]byte) error {
|
func resolverCtrlBlocksEncoder(w io.Writer, val any, buf *[8]byte) error {
|
||||||
if typ, ok := val.(*resolverCtrlBlocks); ok {
|
if typ, ok := val.(*resolverCtrlBlocks); ok {
|
||||||
return (*typ).Encode(w)
|
return (*typ).Encode(w)
|
||||||
@@ -204,7 +167,7 @@ func resolverCtrlBlocksEncoder(w io.Writer, val any, buf *[8]byte) error {
|
|||||||
return tlv.NewTypeForEncodingErr(val, "resolverCtrlBlocks")
|
return tlv.NewTypeForEncodingErr(val, "resolverCtrlBlocks")
|
||||||
}
|
}
|
||||||
|
|
||||||
// rsolverCtrlBlocksDecoder is a custom TLV decoder for the resolverCtrlBlocks
|
// rsolverCtrlBlocksDecoder is a custom TLV decoder for the resolverCtrlBlocks.
|
||||||
func resolverCtrlBlocksDecoder(r io.Reader, val any, buf *[8]byte,
|
func resolverCtrlBlocksDecoder(r io.Reader, val any, buf *[8]byte,
|
||||||
l uint64) error {
|
l uint64) error {
|
||||||
|
|
||||||
@@ -218,6 +181,7 @@ func resolverCtrlBlocksDecoder(r io.Reader, val any, buf *[8]byte,
|
|||||||
}
|
}
|
||||||
|
|
||||||
*typ = resolverBlocks
|
*typ = resolverBlocks
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -315,6 +279,7 @@ func ctrlBlockDecoder(r io.Reader, val any, buf *[8]byte, l uint64) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
*typ = &ctrlBlocks
|
*typ = &ctrlBlocks
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -333,8 +298,10 @@ func newCtrlBlocksRecord(blks **ctrlBlocks) tlv.Record {
|
|||||||
if err := ctrlBlockEncoder(&b, blks, &buf); err != nil {
|
if err := ctrlBlockEncoder(&b, blks, &buf); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return uint64(len(b.Bytes()))
|
return uint64(len(b.Bytes()))
|
||||||
}
|
}
|
||||||
|
|
||||||
return tlv.MakeDynamicRecord(
|
return tlv.MakeDynamicRecord(
|
||||||
taprootCtrlBlockType, blks, recordSize, ctrlBlockEncoder,
|
taprootCtrlBlockType, blks, recordSize, ctrlBlockEncoder,
|
||||||
ctrlBlockDecoder,
|
ctrlBlockDecoder,
|
||||||
@@ -549,7 +516,8 @@ func (h *htlcTapTweaks) Decode(reader io.Reader) error {
|
|||||||
// tapTweaks stores the set of taptweaks needed to perform keyspends for the
|
// tapTweaks stores the set of taptweaks needed to perform keyspends for the
|
||||||
// commitment outputs.
|
// commitment outputs.
|
||||||
type tapTweaks struct {
|
type tapTweaks struct {
|
||||||
// AnchorTweak is the tweak used to derive the key used to spend the anchor output.
|
// AnchorTweak is the tweak used to derive the key used to spend the
|
||||||
|
// anchor output.
|
||||||
AnchorTweak []byte
|
AnchorTweak []byte
|
||||||
|
|
||||||
// BreachedHtlcTweaks stores the set of tweaks needed to sweep the
|
// BreachedHtlcTweaks stores the set of tweaks needed to sweep the
|
||||||
@@ -590,6 +558,7 @@ func tapTweaksDecoder(r io.Reader, val any, buf *[8]byte, l uint64) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
*typ = &tapTweaks
|
*typ = &tapTweaks
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -607,8 +576,10 @@ func newTapTweaksRecord(tweaks **tapTweaks) tlv.Record {
|
|||||||
if err := tapTweaksEncoder(&b, tweaks, &buf); err != nil {
|
if err := tapTweaksEncoder(&b, tweaks, &buf); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return uint64(len(b.Bytes()))
|
return uint64(len(b.Bytes()))
|
||||||
}
|
}
|
||||||
|
|
||||||
return tlv.MakeDynamicRecord(
|
return tlv.MakeDynamicRecord(
|
||||||
taprootTapTweakType, tweaks, recordSize, tapTweaksEncoder,
|
taprootTapTweakType, tweaks, recordSize, tapTweaksEncoder,
|
||||||
tapTweaksDecoder,
|
tapTweaksDecoder,
|
||||||
|
|||||||
@@ -543,10 +543,13 @@ func (u *UtxoNursery) NurseryReport(
|
|||||||
// confirmation of the commitment transaction.
|
// confirmation of the commitment transaction.
|
||||||
switch kid.WitnessType() {
|
switch kid.WitnessType() {
|
||||||
|
|
||||||
case input.HtlcAcceptedSuccessSecondLevel,
|
//nolint:lll
|
||||||
input.TaprootHtlcAcceptedSuccessSecondLevel:
|
case input.TaprootHtlcAcceptedSuccessSecondLevel:
|
||||||
// An HTLC output on our commitment transaction
|
fallthrough
|
||||||
// where the second-layer transaction hasn't
|
case input.HtlcAcceptedSuccessSecondLevel:
|
||||||
|
// An HTLC output on our commitment
|
||||||
|
// transaction where the second-layer
|
||||||
|
// transaction hasn't
|
||||||
// yet confirmed.
|
// yet confirmed.
|
||||||
report.AddLimboStage1SuccessHtlc(&kid)
|
report.AddLimboStage1SuccessHtlc(&kid)
|
||||||
|
|
||||||
@@ -575,6 +578,7 @@ func (u *UtxoNursery) NurseryReport(
|
|||||||
// it.
|
// it.
|
||||||
report.AddLimboDirectHtlc(&kid)
|
report.AddLimboDirectHtlc(&kid)
|
||||||
|
|
||||||
|
//nolint:lll
|
||||||
case input.TaprootHtlcAcceptedSuccessSecondLevel:
|
case input.TaprootHtlcAcceptedSuccessSecondLevel:
|
||||||
fallthrough
|
fallthrough
|
||||||
case input.TaprootHtlcOfferedTimeoutSecondLevel:
|
case input.TaprootHtlcOfferedTimeoutSecondLevel:
|
||||||
@@ -595,6 +599,7 @@ func (u *UtxoNursery) NurseryReport(
|
|||||||
// balance.
|
// balance.
|
||||||
switch kid.WitnessType() {
|
switch kid.WitnessType() {
|
||||||
|
|
||||||
|
//nolint:lll
|
||||||
case input.TaprootHtlcAcceptedSuccessSecondLevel:
|
case input.TaprootHtlcAcceptedSuccessSecondLevel:
|
||||||
fallthrough
|
fallthrough
|
||||||
case input.TaprootHtlcOfferedTimeoutSecondLevel:
|
case input.TaprootHtlcOfferedTimeoutSecondLevel:
|
||||||
|
|||||||
+2
-1
@@ -425,7 +425,8 @@ func MakeHtlcSecondLevelTimeoutAnchorInput(signedTx *wire.MsgTx,
|
|||||||
// transaction. The sweeper is also able to generate witnesses on demand to
|
// transaction. The sweeper is also able to generate witnesses on demand to
|
||||||
// sweep the second level HTLC aggregated with other transactions.
|
// sweep the second level HTLC aggregated with other transactions.
|
||||||
func MakeHtlcSecondLevelTimeoutTaprootInput(signedTx *wire.MsgTx,
|
func MakeHtlcSecondLevelTimeoutTaprootInput(signedTx *wire.MsgTx,
|
||||||
signDetails *SignDetails, heightHint uint32) HtlcSecondLevelAnchorInput {
|
signDetails *SignDetails,
|
||||||
|
heightHint uint32) HtlcSecondLevelAnchorInput {
|
||||||
|
|
||||||
createWitness := func(signer Signer, txn *wire.MsgTx,
|
createWitness := func(signer Signer, txn *wire.MsgTx,
|
||||||
hashCache *txscript.TxSigHashes,
|
hashCache *txscript.TxSigHashes,
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/lnutils"
|
"github.com/lightningnetwork/lnd/lnutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// UnknownScriptTypeErr is returned when an unknown script type is encountered.
|
// ErrUnknownScriptType is returned when an unknown script type is encountered.
|
||||||
var UnknownScriptTypeErr = errors.New("unknown script type")
|
var ErrUnknownScriptType = errors.New("unknown script type")
|
||||||
|
|
||||||
// ScriptPath is used to indicate the spending path of a given script. Possible
|
// ScriptPath is used to indicate the spending path of a given script. Possible
|
||||||
// paths include: timeout, success, revocation, and others.
|
// paths include: timeout, success, revocation, and others.
|
||||||
@@ -28,8 +28,8 @@ const (
|
|||||||
// breached.
|
// breached.
|
||||||
ScriptPathRevocation
|
ScriptPathRevocation
|
||||||
|
|
||||||
// ScriptPathDelay is a script path used when a contract has has
|
// ScriptPathDelay is a script path used when a contract has relative
|
||||||
// relative delay that must elapse before it can be swept.
|
// delay that must elapse before it can be swept.
|
||||||
ScriptPathDelay
|
ScriptPathDelay
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ type ScriptDescriptor interface {
|
|||||||
|
|
||||||
// WitnessScriptForPath returns the witness script for the given
|
// WitnessScriptForPath returns the witness script for the given
|
||||||
// spending path. An error is returned if the path is unknown. This is
|
// spending path. An error is returned if the path is unknown. This is
|
||||||
// useful as when constructing a contrl block for a given path, one
|
// useful as when constructing a control block for a given path, one
|
||||||
// also needs witness script being signed.
|
// also needs witness script being signed.
|
||||||
WitnessScriptForPath(path ScriptPath) ([]byte, error)
|
WitnessScriptForPath(path ScriptPath) ([]byte, error)
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-13
@@ -648,12 +648,12 @@ type HtlcScriptTree struct {
|
|||||||
func (h *HtlcScriptTree) WitnessScriptToSign() []byte {
|
func (h *HtlcScriptTree) WitnessScriptToSign() []byte {
|
||||||
switch h.htlcType {
|
switch h.htlcType {
|
||||||
// For incoming HLTCs on our local commitment, we care about verifying
|
// For incoming HLTCs on our local commitment, we care about verifying
|
||||||
// the sucess path.
|
// the success path.
|
||||||
case htlcLocalIncoming:
|
case htlcLocalIncoming:
|
||||||
return h.SuccessTapLeaf.Script
|
return h.SuccessTapLeaf.Script
|
||||||
|
|
||||||
// For incoming HTLCs on the remote party's commitment, we want to sign
|
// For incoming HTLCs on the remote party's commitment, we want to sign
|
||||||
// the the timeout path for them.
|
// the timeout path for them.
|
||||||
case htlcRemoteIncoming:
|
case htlcRemoteIncoming:
|
||||||
return h.TimeoutTapLeaf.Script
|
return h.TimeoutTapLeaf.Script
|
||||||
|
|
||||||
@@ -1526,7 +1526,7 @@ func SecondLevelHtlcScript(revocationKey, delayKey *btcec.PublicKey,
|
|||||||
// if statement.
|
// if statement.
|
||||||
builder.AddOp(txscript.OP_IF)
|
builder.AddOp(txscript.OP_IF)
|
||||||
|
|
||||||
// If this this is the revocation case, then we'll push the revocation
|
// If this is the revocation case, then we'll push the revocation
|
||||||
// public key on the stack.
|
// public key on the stack.
|
||||||
builder.AddData(revocationKey.SerializeCompressed())
|
builder.AddData(revocationKey.SerializeCompressed())
|
||||||
|
|
||||||
@@ -1778,8 +1778,8 @@ func TaprootHtlcSpendSuccess(signer Signer, signDesc *SignDescriptor,
|
|||||||
|
|
||||||
var ctrlBlock []byte
|
var ctrlBlock []byte
|
||||||
if signDesc.ControlBlock == nil {
|
if signDesc.ControlBlock == nil {
|
||||||
// Now that we have the sweep signature, we'll construct the control
|
// Now that we have the sweep signature, we'll construct the
|
||||||
// block needed to spend the script path.
|
// control block needed to spend the script path.
|
||||||
redeemControlBlock := MakeTaprootCtrlBlock(
|
redeemControlBlock := MakeTaprootCtrlBlock(
|
||||||
signDesc.WitnessScript, revokeKey, tapscriptTree,
|
signDesc.WitnessScript, revokeKey, tapscriptTree,
|
||||||
)
|
)
|
||||||
@@ -1804,9 +1804,9 @@ func TaprootHtlcSpendSuccess(signer Signer, signDesc *SignDescriptor,
|
|||||||
return witnessStack, nil
|
return witnessStack, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// LeaseSecondLevelHtlcScript is the uniform script that's used as the output for
|
// LeaseSecondLevelHtlcScript is the uniform script that's used as the output
|
||||||
// the second-level HTLC transactions. The second level transaction acts as a
|
// for the second-level HTLC transactions. The second level transaction acts as
|
||||||
// sort of covenant, ensuring that a 2-of-2 multi-sig output can only be
|
// a sort of covenant, ensuring that a 2-of-2 multi-sig output can only be
|
||||||
// spent in a particular way, and to a particular output.
|
// spent in a particular way, and to a particular output.
|
||||||
//
|
//
|
||||||
// Possible Input Scripts:
|
// Possible Input Scripts:
|
||||||
@@ -2070,7 +2070,7 @@ var _ TapscriptDescriptor = (*CommitScriptTree)(nil)
|
|||||||
// remote party, and also verifying signatures on our transactions. As an
|
// 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
|
// example, when we create an outgoing HTLC for the remote party, we want to
|
||||||
// sign their success path.
|
// sign their success path.
|
||||||
func (s *CommitScriptTree) WitnessScriptToSign() []byte {
|
func (c *CommitScriptTree) WitnessScriptToSign() []byte {
|
||||||
// TODO(roasbeef): abstraction leak here? always dependent
|
// TODO(roasbeef): abstraction leak here? always dependent
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -2795,20 +2795,20 @@ func NewAnchorScriptTree(anchorKey *btcec.PublicKey,
|
|||||||
// remote party, and also verifying signatures on our transactions. As an
|
// 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
|
// example, when we create an outgoing HTLC for the remote party, we want to
|
||||||
// sign their success path.
|
// sign their success path.
|
||||||
func (s *AnchorScriptTree) WitnessScriptToSign() []byte {
|
func (a *AnchorScriptTree) WitnessScriptToSign() []byte {
|
||||||
return s.SweepLeaf.Script
|
return a.SweepLeaf.Script
|
||||||
}
|
}
|
||||||
|
|
||||||
// WitnessScriptForPath returns the witness script for the given spending path.
|
// WitnessScriptForPath returns the witness script for the given spending path.
|
||||||
// An error is returned if the path is unknown.
|
// An error is returned if the path is unknown.
|
||||||
func (s *AnchorScriptTree) WitnessScriptForPath(path ScriptPath,
|
func (a *AnchorScriptTree) WitnessScriptForPath(path ScriptPath,
|
||||||
) ([]byte, error) {
|
) ([]byte, error) {
|
||||||
|
|
||||||
switch path {
|
switch path {
|
||||||
case ScriptPathDelay:
|
case ScriptPathDelay:
|
||||||
fallthrough
|
fallthrough
|
||||||
case ScriptPathSuccess:
|
case ScriptPathSuccess:
|
||||||
return s.SweepLeaf.Script, nil
|
return a.SweepLeaf.Script, nil
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("unknown script path: %v", path)
|
return nil, fmt.Errorf("unknown script path: %v", path)
|
||||||
|
|||||||
+11
-6
@@ -247,8 +247,8 @@ const (
|
|||||||
// ....HTLCOutputs...
|
// ....HTLCOutputs...
|
||||||
// - LockTime: 4 bytes
|
// - LockTime: 4 bytes
|
||||||
BaseTaprootCommitmentTxWeight = (4 + 1 + FundingInputSize + 3 +
|
BaseTaprootCommitmentTxWeight = (4 + 1 + FundingInputSize + 3 +
|
||||||
2*TaprootCommitmentOutput + 2*TaprootCommitmentAnchorOutput + 4) *
|
2*TaprootCommitmentOutput + 2*TaprootCommitmentAnchorOutput +
|
||||||
witnessScaleFactor
|
4) * witnessScaleFactor
|
||||||
|
|
||||||
// CommitWeight 724 weight.
|
// CommitWeight 724 weight.
|
||||||
CommitWeight = BaseCommitmentTxWeight + WitnessCommitmentTxWeight
|
CommitWeight = BaseCommitmentTxWeight + WitnessCommitmentTxWeight
|
||||||
@@ -637,7 +637,8 @@ const (
|
|||||||
// - ctrl block size: 1 byte
|
// - ctrl block size: 1 byte
|
||||||
// - base control block: 33 bytes
|
// - base control block: 33 bytes
|
||||||
// - merkle proof: 32
|
// - merkle proof: 32
|
||||||
TaprootToLocalRevokeWitnessSize = 1 + 1 + 65 + 1 + TaprootToLocalRevokeScriptSize + 1 + 33 + 32
|
TaprootToLocalRevokeWitnessSize = (1 + 1 + 65 + 1 +
|
||||||
|
TaprootToLocalRevokeScriptSize + 1 + 33 + 32)
|
||||||
|
|
||||||
// TaprootToRemoteScriptSize
|
// TaprootToRemoteScriptSize
|
||||||
// - OP_DATA: 1 byte
|
// - OP_DATA: 1 byte
|
||||||
@@ -656,8 +657,9 @@ const (
|
|||||||
// - taproot_to_local_script_size: 36 bytes
|
// - taproot_to_local_script_size: 36 bytes
|
||||||
// - ctrl_block_len: 1 byte
|
// - ctrl_block_len: 1 byte
|
||||||
// - base_control_block_size: 33 bytes
|
// - base_control_block_size: 33 bytes
|
||||||
TaprootToRemoteWitnessSize = 1 + 1 + 65 + 1 + TaprootToRemoteScriptSize +
|
TaprootToRemoteWitnessSize = (1 + 1 + 65 + 1 +
|
||||||
1 + TaprootBaseControlBlockWitnessSize
|
TaprootToRemoteScriptSize + 1 +
|
||||||
|
TaprootBaseControlBlockWitnessSize)
|
||||||
|
|
||||||
// TaprootAnchorWitnessSize: 67 bytes
|
// TaprootAnchorWitnessSize: 67 bytes
|
||||||
//
|
//
|
||||||
@@ -691,12 +693,14 @@ const (
|
|||||||
// - number_of_witness_elements: 1 byte
|
// - number_of_witness_elements: 1 byte
|
||||||
// - sig_len: 1 byte
|
// - sig_len: 1 byte
|
||||||
// - sweep_sig: 65 bytes (worst case w/o sighash default)
|
// - sweep_sig: 65 bytes (worst case w/o sighash default)
|
||||||
|
//nolint:lll
|
||||||
TaprootSecondLevelRevokeWitnessSize = TaprootKeyPathCustomSighashWitnessSize
|
TaprootSecondLevelRevokeWitnessSize = TaprootKeyPathCustomSighashWitnessSize
|
||||||
|
|
||||||
// TaprootAcceptedRevokeWitnessSize:
|
// TaprootAcceptedRevokeWitnessSize:
|
||||||
// - number_of_witness_elements: 1 byte
|
// - number_of_witness_elements: 1 byte
|
||||||
// - sig_len: 1 byte
|
// - sig_len: 1 byte
|
||||||
// - sweep_sig: 65 bytes (worst case w/o sighash default)
|
// - sweep_sig: 65 bytes (worst case w/o sighash default)
|
||||||
|
//nolint:lll
|
||||||
TaprootAcceptedRevokeWitnessSize = TaprootKeyPathCustomSighashWitnessSize
|
TaprootAcceptedRevokeWitnessSize = TaprootKeyPathCustomSighashWitnessSize
|
||||||
|
|
||||||
// TaprootOfferedRevokeWitnessSize:
|
// TaprootOfferedRevokeWitnessSize:
|
||||||
@@ -716,7 +720,8 @@ const (
|
|||||||
// - cltv_expiry: 4 bytes
|
// - cltv_expiry: 4 bytes
|
||||||
// - OP_CHECKLOCKTIMEVERIFY: 1 byte
|
// - OP_CHECKLOCKTIMEVERIFY: 1 byte
|
||||||
// - OP_DROP: 1 byte
|
// - OP_DROP: 1 byte
|
||||||
TaprootHtlcOfferedRemoteTimeoutScriptSize = 1 + 32 + 1 + 1 + 1 + 1 + 1 + 4 + 1 + 1
|
TaprootHtlcOfferedRemoteTimeoutScriptSize = (1 + 32 + 1 + 1 + 1 + 1 +
|
||||||
|
1 + 4 + 1 + 1)
|
||||||
|
|
||||||
// TaprootHtlcOfferedRemoteTimeoutwitSize: 176 bytes
|
// TaprootHtlcOfferedRemoteTimeoutwitSize: 176 bytes
|
||||||
// - number_of_witness_elements: 1 byte
|
// - number_of_witness_elements: 1 byte
|
||||||
|
|||||||
+33
-12
@@ -850,7 +850,8 @@ var witnessSizeTests = []witnessSizeTest{
|
|||||||
|
|
||||||
signer := &dummySigner{}
|
signer := &dummySigner{}
|
||||||
commitScriptTree, err := input.NewLocalCommitScriptTree(
|
commitScriptTree, err := input.NewLocalCommitScriptTree(
|
||||||
testCSVDelay, testKey.PubKey(), testKey.PubKey(),
|
testCSVDelay, testKey.PubKey(),
|
||||||
|
testKey.PubKey(),
|
||||||
)
|
)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@@ -858,10 +859,11 @@ var witnessSizeTests = []witnessSizeTest{
|
|||||||
KeyDesc: keychain.KeyDescriptor{
|
KeyDesc: keychain.KeyDescriptor{
|
||||||
PubKey: testKey.PubKey(),
|
PubKey: testKey.PubKey(),
|
||||||
},
|
},
|
||||||
|
//nolint:lll
|
||||||
WitnessScript: commitScriptTree.SettleLeaf.Script,
|
WitnessScript: commitScriptTree.SettleLeaf.Script,
|
||||||
HashType: txscript.SigHashAll,
|
HashType: txscript.SigHashAll,
|
||||||
InputIndex: 0,
|
InputIndex: 0,
|
||||||
SignMethod: input.TaprootScriptSpendSignMethod,
|
SignMethod: input.TaprootScriptSpendSignMethod, //nolint:lll
|
||||||
}
|
}
|
||||||
|
|
||||||
witness, err := input.TaprootCommitSpendSuccess(
|
witness, err := input.TaprootCommitSpendSuccess(
|
||||||
@@ -869,6 +871,7 @@ var witnessSizeTests = []witnessSizeTest{
|
|||||||
commitScriptTree.TapscriptTree,
|
commitScriptTree.TapscriptTree,
|
||||||
)
|
)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
return witness
|
return witness
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -881,7 +884,8 @@ var witnessSizeTests = []witnessSizeTest{
|
|||||||
|
|
||||||
signer := &dummySigner{}
|
signer := &dummySigner{}
|
||||||
commitScriptTree, err := input.NewLocalCommitScriptTree(
|
commitScriptTree, err := input.NewLocalCommitScriptTree(
|
||||||
testCSVDelay, testKey.PubKey(), testKey.PubKey(),
|
testCSVDelay, testKey.PubKey(),
|
||||||
|
testKey.PubKey(),
|
||||||
)
|
)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@@ -889,10 +893,11 @@ var witnessSizeTests = []witnessSizeTest{
|
|||||||
KeyDesc: keychain.KeyDescriptor{
|
KeyDesc: keychain.KeyDescriptor{
|
||||||
PubKey: testKey.PubKey(),
|
PubKey: testKey.PubKey(),
|
||||||
},
|
},
|
||||||
|
//nolint:lll
|
||||||
WitnessScript: commitScriptTree.RevocationLeaf.Script,
|
WitnessScript: commitScriptTree.RevocationLeaf.Script,
|
||||||
HashType: txscript.SigHashAll,
|
HashType: txscript.SigHashAll,
|
||||||
InputIndex: 0,
|
InputIndex: 0,
|
||||||
SignMethod: input.TaprootScriptSpendSignMethod,
|
SignMethod: input.TaprootScriptSpendSignMethod, //nolint:lll
|
||||||
}
|
}
|
||||||
|
|
||||||
witness, err := input.TaprootCommitSpendRevoke(
|
witness, err := input.TaprootCommitSpendRevoke(
|
||||||
@@ -900,6 +905,7 @@ var witnessSizeTests = []witnessSizeTest{
|
|||||||
commitScriptTree.TapscriptTree,
|
commitScriptTree.TapscriptTree,
|
||||||
)
|
)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
return witness
|
return witness
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -911,6 +917,7 @@ var witnessSizeTests = []witnessSizeTest{
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
signer := &dummySigner{}
|
signer := &dummySigner{}
|
||||||
|
//nolint:lll
|
||||||
commitScriptTree, err := input.NewRemoteCommitScriptTree(
|
commitScriptTree, err := input.NewRemoteCommitScriptTree(
|
||||||
testKey.PubKey(),
|
testKey.PubKey(),
|
||||||
)
|
)
|
||||||
@@ -920,10 +927,11 @@ var witnessSizeTests = []witnessSizeTest{
|
|||||||
KeyDesc: keychain.KeyDescriptor{
|
KeyDesc: keychain.KeyDescriptor{
|
||||||
PubKey: testKey.PubKey(),
|
PubKey: testKey.PubKey(),
|
||||||
},
|
},
|
||||||
|
//nolint:lll
|
||||||
WitnessScript: commitScriptTree.SettleLeaf.Script,
|
WitnessScript: commitScriptTree.SettleLeaf.Script,
|
||||||
HashType: txscript.SigHashAll,
|
HashType: txscript.SigHashAll,
|
||||||
InputIndex: 0,
|
InputIndex: 0,
|
||||||
SignMethod: input.TaprootScriptSpendSignMethod,
|
SignMethod: input.TaprootScriptSpendSignMethod, //nolint:lll
|
||||||
}
|
}
|
||||||
|
|
||||||
witness, err := input.TaprootCommitRemoteSpend(
|
witness, err := input.TaprootCommitRemoteSpend(
|
||||||
@@ -931,6 +939,7 @@ var witnessSizeTests = []witnessSizeTest{
|
|||||||
commitScriptTree.TapscriptTree,
|
commitScriptTree.TapscriptTree,
|
||||||
)
|
)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
return witness
|
return witness
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -962,6 +971,7 @@ var witnessSizeTests = []witnessSizeTest{
|
|||||||
signer, signDesc, testTx,
|
signer, signDesc, testTx,
|
||||||
)
|
)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
return witness
|
return witness
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -1002,6 +1012,7 @@ var witnessSizeTests = []witnessSizeTest{
|
|||||||
scriptTree,
|
scriptTree,
|
||||||
)
|
)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
return witness
|
return witness
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -1038,6 +1049,7 @@ var witnessSizeTests = []witnessSizeTest{
|
|||||||
signer, signDesc, testTx,
|
signer, signDesc, testTx,
|
||||||
)
|
)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
return witness
|
return witness
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -1062,6 +1074,7 @@ var witnessSizeTests = []witnessSizeTest{
|
|||||||
senderKey.PubKey(), receiverKey.PubKey(),
|
senderKey.PubKey(), receiverKey.PubKey(),
|
||||||
revokeKey.PubKey(), payHash[:], false,
|
revokeKey.PubKey(), payHash[:], false,
|
||||||
)
|
)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
signDesc := &input.SignDescriptor{
|
signDesc := &input.SignDescriptor{
|
||||||
KeyDesc: keychain.KeyDescriptor{
|
KeyDesc: keychain.KeyDescriptor{
|
||||||
@@ -1077,6 +1090,7 @@ var witnessSizeTests = []witnessSizeTest{
|
|||||||
signer, signDesc, testTx,
|
signer, signDesc, testTx,
|
||||||
)
|
)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
return witness
|
return witness
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -1102,6 +1116,7 @@ var witnessSizeTests = []witnessSizeTest{
|
|||||||
receiverKey.PubKey(), revokeKey.PubKey(),
|
receiverKey.PubKey(), revokeKey.PubKey(),
|
||||||
payHash[:], false,
|
payHash[:], false,
|
||||||
)
|
)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
signDesc := &input.SignDescriptor{
|
signDesc := &input.SignDescriptor{
|
||||||
KeyDesc: keychain.KeyDescriptor{
|
KeyDesc: keychain.KeyDescriptor{
|
||||||
@@ -1117,6 +1132,7 @@ var witnessSizeTests = []witnessSizeTest{
|
|||||||
signer, signDesc, testTx,
|
signer, signDesc, testTx,
|
||||||
)
|
)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
return witness
|
return witness
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -1142,6 +1158,7 @@ var witnessSizeTests = []witnessSizeTest{
|
|||||||
receiverKey.PubKey(), revokeKey.PubKey(),
|
receiverKey.PubKey(), revokeKey.PubKey(),
|
||||||
payHash[:], false,
|
payHash[:], false,
|
||||||
)
|
)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
timeoutLeaf := htlcScriptTree.TimeoutTapLeaf
|
timeoutLeaf := htlcScriptTree.TimeoutTapLeaf
|
||||||
|
|
||||||
@@ -1152,14 +1169,16 @@ var witnessSizeTests = []witnessSizeTest{
|
|||||||
WitnessScript: timeoutLeaf.Script,
|
WitnessScript: timeoutLeaf.Script,
|
||||||
HashType: txscript.SigHashAll,
|
HashType: txscript.SigHashAll,
|
||||||
InputIndex: 0,
|
InputIndex: 0,
|
||||||
SignMethod: input.TaprootScriptSpendSignMethod,
|
SignMethod: input.TaprootScriptSpendSignMethod, //nolint:lll
|
||||||
}
|
}
|
||||||
|
|
||||||
witness, err := input.ReceiverHTLCScriptTaprootTimeout(
|
witness, err := input.ReceiverHTLCScriptTaprootTimeout(
|
||||||
signer, signDesc, testTx, testCLTVExpiry,
|
signer, signDesc, testTx, testCLTVExpiry,
|
||||||
revokeKey.PubKey(), htlcScriptTree.TapscriptTree,
|
revokeKey.PubKey(),
|
||||||
|
htlcScriptTree.TapscriptTree,
|
||||||
)
|
)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
return witness
|
return witness
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -1197,7 +1216,7 @@ var witnessSizeTests = []witnessSizeTest{
|
|||||||
WitnessScript: timeoutLeaf.Script,
|
WitnessScript: timeoutLeaf.Script,
|
||||||
HashType: txscript.SigHashAll,
|
HashType: txscript.SigHashAll,
|
||||||
InputIndex: 0,
|
InputIndex: 0,
|
||||||
SignMethod: input.TaprootScriptSpendSignMethod,
|
SignMethod: input.TaprootScriptSpendSignMethod, //nolint:lll
|
||||||
}
|
}
|
||||||
receiverSig, err := signer.SignOutputRaw(
|
receiverSig, err := signer.SignOutputRaw(
|
||||||
testTx, receiverDesc,
|
testTx, receiverDesc,
|
||||||
@@ -1211,7 +1230,7 @@ var witnessSizeTests = []witnessSizeTest{
|
|||||||
WitnessScript: timeoutLeaf.Script,
|
WitnessScript: timeoutLeaf.Script,
|
||||||
HashType: txscript.SigHashAll,
|
HashType: txscript.SigHashAll,
|
||||||
InputIndex: 0,
|
InputIndex: 0,
|
||||||
SignMethod: input.TaprootScriptSpendSignMethod,
|
SignMethod: input.TaprootScriptSpendSignMethod, //nolint:lll
|
||||||
}
|
}
|
||||||
|
|
||||||
witness, err := input.SenderHTLCScriptTaprootTimeout(
|
witness, err := input.SenderHTLCScriptTaprootTimeout(
|
||||||
@@ -1220,6 +1239,7 @@ var witnessSizeTests = []witnessSizeTest{
|
|||||||
scriptTree,
|
scriptTree,
|
||||||
)
|
)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
return witness
|
return witness
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -1256,7 +1276,7 @@ var witnessSizeTests = []witnessSizeTest{
|
|||||||
WitnessScript: successLeaf.Script,
|
WitnessScript: successLeaf.Script,
|
||||||
HashType: txscript.SigHashAll,
|
HashType: txscript.SigHashAll,
|
||||||
InputIndex: 0,
|
InputIndex: 0,
|
||||||
SignMethod: input.TaprootScriptSpendSignMethod,
|
SignMethod: input.TaprootScriptSpendSignMethod, //nolint:lll
|
||||||
}
|
}
|
||||||
|
|
||||||
witness, err := input.SenderHTLCScriptTaprootRedeem(
|
witness, err := input.SenderHTLCScriptTaprootRedeem(
|
||||||
@@ -1290,6 +1310,7 @@ var witnessSizeTests = []witnessSizeTest{
|
|||||||
receiverKey.PubKey(), revokeKey.PubKey(),
|
receiverKey.PubKey(), revokeKey.PubKey(),
|
||||||
payHash[:], false,
|
payHash[:], false,
|
||||||
)
|
)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
successsLeaf := htlcScriptTree.SuccessTapLeaf
|
successsLeaf := htlcScriptTree.SuccessTapLeaf
|
||||||
scriptTree := htlcScriptTree.TapscriptTree
|
scriptTree := htlcScriptTree.TapscriptTree
|
||||||
@@ -1301,7 +1322,7 @@ var witnessSizeTests = []witnessSizeTest{
|
|||||||
WitnessScript: successsLeaf.Script,
|
WitnessScript: successsLeaf.Script,
|
||||||
HashType: txscript.SigHashAll,
|
HashType: txscript.SigHashAll,
|
||||||
InputIndex: 0,
|
InputIndex: 0,
|
||||||
SignMethod: input.TaprootScriptSpendSignMethod,
|
SignMethod: input.TaprootScriptSpendSignMethod, //nolint:lll
|
||||||
}
|
}
|
||||||
senderSig, err := signer.SignOutputRaw(
|
senderSig, err := signer.SignOutputRaw(
|
||||||
testTx, senderDesc,
|
testTx, senderDesc,
|
||||||
@@ -1315,7 +1336,7 @@ var witnessSizeTests = []witnessSizeTest{
|
|||||||
WitnessScript: successsLeaf.Script,
|
WitnessScript: successsLeaf.Script,
|
||||||
HashType: txscript.SigHashAll,
|
HashType: txscript.SigHashAll,
|
||||||
InputIndex: 0,
|
InputIndex: 0,
|
||||||
SignMethod: input.TaprootScriptSpendSignMethod,
|
SignMethod: input.TaprootScriptSpendSignMethod, //nolint:lll
|
||||||
}
|
}
|
||||||
|
|
||||||
witness, err := input.ReceiverHTLCScriptTaprootRedeem(
|
witness, err := input.ReceiverHTLCScriptTaprootRedeem(
|
||||||
|
|||||||
+8
-8
@@ -522,8 +522,8 @@ func (wt StandardWitnessType) WitnessGenerator(signer Signer,
|
|||||||
|
|
||||||
// The control block bytes must be set at this point.
|
// The control block bytes must be set at this point.
|
||||||
if desc.ControlBlock == nil {
|
if desc.ControlBlock == nil {
|
||||||
return nil, fmt.Errorf("control block must be " +
|
return nil, fmt.Errorf("control block must " +
|
||||||
"set for taproot spend")
|
"be set for taproot spend")
|
||||||
}
|
}
|
||||||
|
|
||||||
witness, err := TaprootCommitSpendSuccess(
|
witness, err := TaprootCommitSpendSuccess(
|
||||||
@@ -544,8 +544,8 @@ func (wt StandardWitnessType) WitnessGenerator(signer Signer,
|
|||||||
|
|
||||||
// The control block bytes must be set at this point.
|
// The control block bytes must be set at this point.
|
||||||
if desc.ControlBlock == nil {
|
if desc.ControlBlock == nil {
|
||||||
return nil, fmt.Errorf("control block must be " +
|
return nil, fmt.Errorf("control block must " +
|
||||||
"set for taproot spend")
|
"be set for taproot spend")
|
||||||
}
|
}
|
||||||
|
|
||||||
witness, err := TaprootCommitRemoteSpend(
|
witness, err := TaprootCommitRemoteSpend(
|
||||||
@@ -589,8 +589,8 @@ func (wt StandardWitnessType) WitnessGenerator(signer Signer,
|
|||||||
|
|
||||||
// The control block bytes must be set at this point.
|
// The control block bytes must be set at this point.
|
||||||
if desc.ControlBlock == nil {
|
if desc.ControlBlock == nil {
|
||||||
return nil, fmt.Errorf("control block must be " +
|
return nil, fmt.Errorf("control block must " +
|
||||||
"set for taproot spend")
|
"be set for taproot spend")
|
||||||
}
|
}
|
||||||
|
|
||||||
witness, err := TaprootHtlcSpendSuccess(
|
witness, err := TaprootHtlcSpendSuccess(
|
||||||
@@ -677,8 +677,8 @@ func (wt StandardWitnessType) WitnessGenerator(signer Signer,
|
|||||||
|
|
||||||
// The control block bytes must be set at this point.
|
// The control block bytes must be set at this point.
|
||||||
if desc.ControlBlock == nil {
|
if desc.ControlBlock == nil {
|
||||||
return nil, fmt.Errorf("control block must be " +
|
return nil, fmt.Errorf("control block " +
|
||||||
"set for taproot spend")
|
"must be set for taproot spend")
|
||||||
}
|
}
|
||||||
|
|
||||||
witness, err := ReceiverHTLCScriptTaprootTimeout(
|
witness, err := ReceiverHTLCScriptTaprootTimeout(
|
||||||
|
|||||||
@@ -719,7 +719,6 @@ func channelForceClosureTest(ht *lntest.HarnessTest,
|
|||||||
|
|
||||||
// In case of anchors, the timeout txs will be aggregated into one.
|
// In case of anchors, the timeout txs will be aggregated into one.
|
||||||
if lntest.CommitTypeHasAnchors(channelType) {
|
if lntest.CommitTypeHasAnchors(channelType) {
|
||||||
|
|
||||||
expectedTxes = 1
|
expectedTxes = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -733,7 +732,6 @@ func channelForceClosureTest(ht *lntest.HarnessTest,
|
|||||||
// into one.
|
// into one.
|
||||||
numInputs := 1
|
numInputs := 1
|
||||||
if lntest.CommitTypeHasAnchors(channelType) {
|
if lntest.CommitTypeHasAnchors(channelType) {
|
||||||
|
|
||||||
numInputs = numInvoices + 1
|
numInputs = numInvoices + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -845,7 +843,6 @@ func channelForceClosureTest(ht *lntest.HarnessTest,
|
|||||||
// For anchor channels thhis is one block earlier.
|
// For anchor channels thhis is one block earlier.
|
||||||
numBlocks := uint32(defaultCSV - 1)
|
numBlocks := uint32(defaultCSV - 1)
|
||||||
if lntest.CommitTypeHasAnchors(channelType) {
|
if lntest.CommitTypeHasAnchors(channelType) {
|
||||||
|
|
||||||
numBlocks = defaultCSV - 2
|
numBlocks = defaultCSV - 2
|
||||||
}
|
}
|
||||||
ht.MineBlocks(numBlocks)
|
ht.MineBlocks(numBlocks)
|
||||||
@@ -992,7 +989,6 @@ func channelForceClosureTest(ht *lntest.HarnessTest,
|
|||||||
// In addition, if this is an anchor-enabled channel, further add the
|
// In addition, if this is an anchor-enabled channel, further add the
|
||||||
// anchor size.
|
// anchor size.
|
||||||
if lntest.CommitTypeHasAnchors(channelType) {
|
if lntest.CommitTypeHasAnchors(channelType) {
|
||||||
|
|
||||||
carolExpectedBalance += btcutil.Amount(anchorSize)
|
carolExpectedBalance += btcutil.Amount(anchorSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -102,13 +102,14 @@ func testBasicChannelFunding(ht *lntest.HarnessTest) {
|
|||||||
// Dave only supports tweakless, channel will be downgraded to
|
// Dave only supports tweakless, channel will be downgraded to
|
||||||
// this type if Carol supports anchors.
|
// this type if Carol supports anchors.
|
||||||
case lnrpc.CommitmentType_STATIC_REMOTE_KEY:
|
case lnrpc.CommitmentType_STATIC_REMOTE_KEY:
|
||||||
if expType == lnrpc.CommitmentType_ANCHORS {
|
switch expType {
|
||||||
|
case lnrpc.CommitmentType_ANCHORS:
|
||||||
expType = lnrpc.CommitmentType_STATIC_REMOTE_KEY
|
expType = lnrpc.CommitmentType_STATIC_REMOTE_KEY
|
||||||
} else if expType == lnrpc.CommitmentType_SIMPLE_TAPROOT {
|
case lnrpc.CommitmentType_SIMPLE_TAPROOT:
|
||||||
expType = lnrpc.CommitmentType_STATIC_REMOTE_KEY
|
expType = lnrpc.CommitmentType_STATIC_REMOTE_KEY
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dave only supoprts legacy type, channel will be downgraded
|
// Dave only supports legacy type, channel will be downgraded
|
||||||
// to this type.
|
// to this type.
|
||||||
case lnrpc.CommitmentType_LEGACY:
|
case lnrpc.CommitmentType_LEGACY:
|
||||||
expType = lnrpc.CommitmentType_LEGACY
|
expType = lnrpc.CommitmentType_LEGACY
|
||||||
|
|||||||
@@ -37,7 +37,8 @@ func breachRetributionTestCase(ht *lntest.HarnessTest,
|
|||||||
"Carol",
|
"Carol",
|
||||||
append(
|
append(
|
||||||
nodeArgs,
|
nodeArgs,
|
||||||
[]string{"--hodl.exit-settle", "--nolisten", "--minbackoff=1h"}...,
|
[]string{"--hodl.exit-settle", "--nolisten",
|
||||||
|
"--minbackoff=1h"}...,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -55,9 +55,10 @@ func (d *DummySigner) ComputeInputScript(tx *wire.MsgTx,
|
|||||||
// all signing parties must be provided, including the public key of the local
|
// all signing parties must be provided, including the public key of the local
|
||||||
// signing key. If nonces of other parties are already known, they can be
|
// signing key. If nonces of other parties are already known, they can be
|
||||||
// submitted as well to reduce the number of method calls necessary later on.
|
// submitted as well to reduce the number of method calls necessary later on.
|
||||||
func (d *DummySigner) MuSig2CreateSession(input.MuSig2Version, keychain.KeyLocator,
|
func (d *DummySigner) MuSig2CreateSession(input.MuSig2Version,
|
||||||
[]*btcec.PublicKey, *input.MuSig2Tweaks,
|
keychain.KeyLocator, []*btcec.PublicKey, *input.MuSig2Tweaks,
|
||||||
[][musig2.PubNonceSize]byte, ...musig2.SessionOption) (*input.MuSig2SessionInfo, error) {
|
[][musig2.PubNonceSize]byte, ...musig2.SessionOption,
|
||||||
|
) (*input.MuSig2SessionInfo, error) {
|
||||||
|
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|||||||
+23
-5
@@ -2513,8 +2513,8 @@ func NewBreachRetribution(chanState *channeldb.OpenChannel, stateNum uint64,
|
|||||||
// If our balance exceeds the remote party's dust limit, instantiate
|
// If our balance exceeds the remote party's dust limit, instantiate
|
||||||
// the sign descriptor for our output.
|
// the sign descriptor for our output.
|
||||||
if ourAmt >= int64(chanState.RemoteChanCfg.DustLimit) {
|
if ourAmt >= int64(chanState.RemoteChanCfg.DustLimit) {
|
||||||
// As we're about to sweep our own output w/o a delay, we'll obtain
|
// As we're about to sweep our own output w/o a delay, we'll
|
||||||
// the witness script for the success/delay path.
|
// obtain the witness script for the success/delay path.
|
||||||
witnessScript, err := ourScript.WitnessScriptForPath(
|
witnessScript, err := ourScript.WitnessScriptForPath(
|
||||||
input.ScriptPathDelay,
|
input.ScriptPathDelay,
|
||||||
)
|
)
|
||||||
@@ -2537,6 +2537,7 @@ func NewBreachRetribution(chanState *channeldb.OpenChannel, stateNum uint64,
|
|||||||
// spend (as our output on their revoked tx still needs the
|
// spend (as our output on their revoked tx still needs the
|
||||||
// delay), and set the control block.
|
// delay), and set the control block.
|
||||||
if scriptTree, ok := ourScript.(input.TapscriptDescriptor); ok {
|
if scriptTree, ok := ourScript.(input.TapscriptDescriptor); ok {
|
||||||
|
//nolint:lll
|
||||||
br.LocalOutputSignDesc.SignMethod = input.TaprootScriptSpendSignMethod
|
br.LocalOutputSignDesc.SignMethod = input.TaprootScriptSpendSignMethod
|
||||||
|
|
||||||
ctrlBlock, err := scriptTree.CtrlBlockForPath(
|
ctrlBlock, err := scriptTree.CtrlBlockForPath(
|
||||||
@@ -2546,6 +2547,7 @@ func NewBreachRetribution(chanState *channeldb.OpenChannel, stateNum uint64,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint:lll
|
||||||
br.LocalOutputSignDesc.ControlBlock, err = ctrlBlock.ToBytes()
|
br.LocalOutputSignDesc.ControlBlock, err = ctrlBlock.ToBytes()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -2581,7 +2583,8 @@ func NewBreachRetribution(chanState *channeldb.OpenChannel, stateNum uint64,
|
|||||||
// For taproot channels, the remote output (the revoked output)
|
// For taproot channels, the remote output (the revoked output)
|
||||||
// is spent with a script path to ensure all information 3rd
|
// is spent with a script path to ensure all information 3rd
|
||||||
// parties need to sweep anchors is revealed on chain.
|
// parties need to sweep anchors is revealed on chain.
|
||||||
if scriptTree, ok := theirScript.(input.TapscriptDescriptor); ok {
|
scriptTree, ok := theirScript.(input.TapscriptDescriptor)
|
||||||
|
if ok {
|
||||||
//nolint:lll
|
//nolint:lll
|
||||||
br.RemoteOutputSignDesc.SignMethod = input.TaprootScriptSpendSignMethod
|
br.RemoteOutputSignDesc.SignMethod = input.TaprootScriptSpendSignMethod
|
||||||
|
|
||||||
@@ -2591,6 +2594,7 @@ func NewBreachRetribution(chanState *channeldb.OpenChannel, stateNum uint64,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
//nolint:lll
|
||||||
br.RemoteOutputSignDesc.ControlBlock, err = ctrlBlock.ToBytes()
|
br.RemoteOutputSignDesc.ControlBlock, err = ctrlBlock.ToBytes()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -6480,6 +6484,8 @@ func NewUnilateralCloseSummary(chanState *channeldb.OpenChannel, signer input.Si
|
|||||||
|
|
||||||
// For taproot channels, we'll need to set some additional
|
// For taproot channels, we'll need to set some additional
|
||||||
// fields to ensure the output can be swept.
|
// fields to ensure the output can be swept.
|
||||||
|
//
|
||||||
|
//nolint:lll
|
||||||
if scriptTree, ok := selfScript.(input.TapscriptDescriptor); ok {
|
if scriptTree, ok := selfScript.(input.TapscriptDescriptor); ok {
|
||||||
commitResolution.SelfOutputSignDesc.SignMethod =
|
commitResolution.SelfOutputSignDesc.SignMethod =
|
||||||
input.TaprootScriptSpendSignMethod
|
input.TaprootScriptSpendSignMethod
|
||||||
@@ -6490,6 +6496,7 @@ func NewUnilateralCloseSummary(chanState *channeldb.OpenChannel, signer input.Si
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
//nolint:lll
|
||||||
commitResolution.SelfOutputSignDesc.ControlBlock, err = ctrlBlock.ToBytes()
|
commitResolution.SelfOutputSignDesc.ControlBlock, err = ctrlBlock.ToBytes()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -6836,6 +6843,7 @@ func newOutgoingHtlcResolution(signer input.Signer,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
//nolint:lll
|
||||||
secondLevelScriptTree, err := input.TaprootSecondLevelScriptTree(
|
secondLevelScriptTree, err := input.TaprootSecondLevelScriptTree(
|
||||||
keyRing.RevocationKey, keyRing.ToLocalKey, csvDelay,
|
keyRing.RevocationKey, keyRing.ToLocalKey, csvDelay,
|
||||||
)
|
)
|
||||||
@@ -6952,9 +6960,12 @@ func newIncomingHtlcResolution(signer input.Signer,
|
|||||||
HashType: txscript.SigHashAll,
|
HashType: txscript.SigHashAll,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint:lll
|
||||||
if scriptTree, ok := scriptInfo.(input.TapscriptDescriptor); ok {
|
if scriptTree, ok := scriptInfo.(input.TapscriptDescriptor); ok {
|
||||||
signDesc.SignMethod = input.TaprootScriptSpendSignMethod
|
signDesc.SignMethod = input.TaprootScriptSpendSignMethod
|
||||||
ctrlBlock, err := scriptTree.CtrlBlockForPath(scriptPath)
|
ctrlBlock, err := scriptTree.CtrlBlockForPath(
|
||||||
|
scriptPath,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -6979,7 +6990,8 @@ func newIncomingHtlcResolution(signer input.Signer,
|
|||||||
secondLevelOutputAmt := htlc.Amt.ToSatoshis() - htlcFee
|
secondLevelOutputAmt := htlc.Amt.ToSatoshis() - htlcFee
|
||||||
successTx, err := CreateHtlcSuccessTx(
|
successTx, err := CreateHtlcSuccessTx(
|
||||||
chanType, isCommitFromInitiator, op, secondLevelOutputAmt,
|
chanType, isCommitFromInitiator, op, secondLevelOutputAmt,
|
||||||
csvDelay, leaseExpiry, keyRing.RevocationKey, keyRing.ToLocalKey,
|
csvDelay, leaseExpiry, keyRing.RevocationKey,
|
||||||
|
keyRing.ToLocalKey,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -7068,6 +7080,7 @@ func newIncomingHtlcResolution(signer input.Signer,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
//nolint:lll
|
||||||
secondLevelScriptTree, err := input.TaprootSecondLevelScriptTree(
|
secondLevelScriptTree, err := input.TaprootSecondLevelScriptTree(
|
||||||
keyRing.RevocationKey, keyRing.ToLocalKey, csvDelay,
|
keyRing.RevocationKey, keyRing.ToLocalKey, csvDelay,
|
||||||
)
|
)
|
||||||
@@ -7429,6 +7442,7 @@ func NewLocalForceCloseSummary(chanState *channeldb.OpenChannel,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
//nolint:lll
|
||||||
commitResolution.SelfOutputSignDesc.ControlBlock, err = ctrlBlock.ToBytes()
|
commitResolution.SelfOutputSignDesc.ControlBlock, err = ctrlBlock.ToBytes()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -7823,6 +7837,7 @@ func NewAnchorResolution(chanState *channeldb.OpenChannel,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if chanState.ChanType.IsTaproot() && !isLocalCommit {
|
if chanState.ChanType.IsTaproot() && !isLocalCommit {
|
||||||
|
//nolint:ineffassign
|
||||||
localAnchor, remoteAnchor = remoteAnchor, localAnchor
|
localAnchor, remoteAnchor = remoteAnchor, localAnchor
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7868,6 +7883,7 @@ func NewAnchorResolution(chanState *channeldb.OpenChannel,
|
|||||||
signDesc.SignMethod = input.TaprootKeySpendSignMethod
|
signDesc.SignMethod = input.TaprootKeySpendSignMethod
|
||||||
signDesc.HashType = txscript.SigHashDefault
|
signDesc.HashType = txscript.SigHashDefault
|
||||||
|
|
||||||
|
//nolint:lll
|
||||||
signDesc.PrevOutputFetcher = txscript.NewCannedPrevOutputFetcher(
|
signDesc.PrevOutputFetcher = txscript.NewCannedPrevOutputFetcher(
|
||||||
localAnchor.PkScript(), int64(anchorSize),
|
localAnchor.PkScript(), int64(anchorSize),
|
||||||
)
|
)
|
||||||
@@ -7888,6 +7904,8 @@ func NewAnchorResolution(chanState *channeldb.OpenChannel,
|
|||||||
// When we're playing the force close of a remote
|
// When we're playing the force close of a remote
|
||||||
// commitment, as this is a "tweakless" channel type,
|
// commitment, as this is a "tweakless" channel type,
|
||||||
// we don't need a tweak value at all.
|
// we don't need a tweak value at all.
|
||||||
|
//
|
||||||
|
//nolint:lll
|
||||||
signDesc.KeyDesc = chanState.LocalChanCfg.PaymentBasePoint
|
signDesc.KeyDesc = chanState.LocalChanCfg.PaymentBasePoint
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+11
-9
@@ -425,6 +425,9 @@ func SecondLevelHtlcScript(chanType channeldb.ChannelType, initiator bool,
|
|||||||
witnessScript, err := input.LeaseSecondLevelHtlcScript(
|
witnessScript, err := input.LeaseSecondLevelHtlcScript(
|
||||||
revocationKey, delayKey, csvDelay, leaseExpiry,
|
revocationKey, delayKey, csvDelay, leaseExpiry,
|
||||||
)
|
)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
pkScript, err := input.WitnessScriptHash(witnessScript)
|
pkScript, err := input.WitnessScriptHash(witnessScript)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -440,6 +443,9 @@ func SecondLevelHtlcScript(chanType channeldb.ChannelType, initiator bool,
|
|||||||
witnessScript, err := input.SecondLevelHtlcScript(
|
witnessScript, err := input.SecondLevelHtlcScript(
|
||||||
revocationKey, delayKey, csvDelay,
|
revocationKey, delayKey, csvDelay,
|
||||||
)
|
)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
pkScript, err := input.WitnessScriptHash(witnessScript)
|
pkScript, err := input.WitnessScriptHash(witnessScript)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -528,6 +534,7 @@ func CommitScriptAnchors(chanType channeldb.ChannelType,
|
|||||||
case chanType.IsTaproot():
|
case chanType.IsTaproot():
|
||||||
anchorScript = func(key *btcec.PublicKey,
|
anchorScript = func(key *btcec.PublicKey,
|
||||||
) (input.ScriptDescriptor, error) {
|
) (input.ScriptDescriptor, error) {
|
||||||
|
|
||||||
return input.NewAnchorScriptTree(
|
return input.NewAnchorScriptTree(
|
||||||
key,
|
key,
|
||||||
)
|
)
|
||||||
@@ -1096,9 +1103,6 @@ func genTaprootHtlcScript(isIncoming, ourCommit bool, timeout uint32,
|
|||||||
keyRing.LocalHtlcKey, keyRing.RemoteHtlcKey,
|
keyRing.LocalHtlcKey, keyRing.RemoteHtlcKey,
|
||||||
keyRing.RevocationKey, rHash[:], ourCommit,
|
keyRing.RevocationKey, rHash[:], ourCommit,
|
||||||
)
|
)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finally, we're paying the remote party via an HTLC, which is being
|
// Finally, we're paying the remote party via an HTLC, which is being
|
||||||
// added to their commitment transaction. Therefore, we use the
|
// added to their commitment transaction. Therefore, we use the
|
||||||
@@ -1108,12 +1112,9 @@ func genTaprootHtlcScript(isIncoming, ourCommit bool, timeout uint32,
|
|||||||
timeout, keyRing.LocalHtlcKey, keyRing.RemoteHtlcKey,
|
timeout, keyRing.LocalHtlcKey, keyRing.RemoteHtlcKey,
|
||||||
keyRing.RevocationKey, rHash[:], ourCommit,
|
keyRing.RevocationKey, rHash[:], ourCommit,
|
||||||
)
|
)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return htlcScriptTree, nil
|
return htlcScriptTree, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// genHtlcScript generates the proper P2WSH public key scripts for the HTLC
|
// genHtlcScript generates the proper P2WSH public key scripts for the HTLC
|
||||||
@@ -1131,12 +1132,12 @@ func genHtlcScript(chanType channeldb.ChannelType, isIncoming, ourCommit bool,
|
|||||||
chanType, isIncoming, ourCommit, timeout, rHash,
|
chanType, isIncoming, ourCommit, timeout, rHash,
|
||||||
keyRing,
|
keyRing,
|
||||||
)
|
)
|
||||||
} else {
|
}
|
||||||
|
|
||||||
return genTaprootHtlcScript(
|
return genTaprootHtlcScript(
|
||||||
isIncoming, ourCommit, timeout, rHash, keyRing,
|
isIncoming, ourCommit, timeout, rHash, keyRing,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// addHTLC adds a new HTLC to the passed commitment transaction. One of four
|
// addHTLC adds a new HTLC to the passed commitment transaction. One of four
|
||||||
// full scripts will be generated for the HTLC output depending on if the HTLC
|
// full scripts will be generated for the HTLC output depending on if the HTLC
|
||||||
@@ -1174,6 +1175,7 @@ func addHTLC(commitTx *wire.MsgTx, ourCommit bool,
|
|||||||
} else {
|
} else {
|
||||||
paymentDesc.theirPkScript = pkScript
|
paymentDesc.theirPkScript = pkScript
|
||||||
|
|
||||||
|
//nolint:lll
|
||||||
paymentDesc.theirWitnessScript = scriptInfo.WitnessScriptToSign()
|
paymentDesc.theirWitnessScript = scriptInfo.WitnessScriptToSign()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user