mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 01:43:16 +01:00
contractcourt: update makeBreachedOutput to accept resolution blob
This commit is contained in:
parent
f81cd79bca
commit
c59f11168b
@ -1078,10 +1078,9 @@ type breachedOutput struct {
|
|||||||
// makeBreachedOutput assembles a new breachedOutput that can be used by the
|
// makeBreachedOutput assembles a new breachedOutput that can be used by the
|
||||||
// breach arbiter to construct a justice or sweep transaction.
|
// breach arbiter to construct a justice or sweep transaction.
|
||||||
func makeBreachedOutput(outpoint *wire.OutPoint,
|
func makeBreachedOutput(outpoint *wire.OutPoint,
|
||||||
witnessType input.StandardWitnessType,
|
witnessType input.StandardWitnessType, secondLevelScript []byte,
|
||||||
secondLevelScript []byte,
|
signDescriptor *input.SignDescriptor, confHeight uint32,
|
||||||
signDescriptor *input.SignDescriptor,
|
resolutionBlob fn.Option[tlv.Blob]) breachedOutput {
|
||||||
confHeight uint32) breachedOutput {
|
|
||||||
|
|
||||||
amount := signDescriptor.Output.Value
|
amount := signDescriptor.Output.Value
|
||||||
|
|
||||||
@ -1092,6 +1091,7 @@ func makeBreachedOutput(outpoint *wire.OutPoint,
|
|||||||
witnessType: witnessType,
|
witnessType: witnessType,
|
||||||
signDesc: *signDescriptor,
|
signDesc: *signDescriptor,
|
||||||
confHeight: confHeight,
|
confHeight: confHeight,
|
||||||
|
resolutionBlob: resolutionBlob,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1270,6 +1270,7 @@ func newRetributionInfo(chanPoint *wire.OutPoint,
|
|||||||
nil,
|
nil,
|
||||||
breachInfo.LocalOutputSignDesc,
|
breachInfo.LocalOutputSignDesc,
|
||||||
breachInfo.BreachHeight,
|
breachInfo.BreachHeight,
|
||||||
|
breachInfo.LocalResolutionBlob,
|
||||||
)
|
)
|
||||||
|
|
||||||
breachedOutputs = append(breachedOutputs, localOutput)
|
breachedOutputs = append(breachedOutputs, localOutput)
|
||||||
@ -1296,6 +1297,7 @@ func newRetributionInfo(chanPoint *wire.OutPoint,
|
|||||||
nil,
|
nil,
|
||||||
breachInfo.RemoteOutputSignDesc,
|
breachInfo.RemoteOutputSignDesc,
|
||||||
breachInfo.BreachHeight,
|
breachInfo.BreachHeight,
|
||||||
|
breachInfo.RemoteResolutionBlob,
|
||||||
)
|
)
|
||||||
|
|
||||||
breachedOutputs = append(breachedOutputs, remoteOutput)
|
breachedOutputs = append(breachedOutputs, remoteOutput)
|
||||||
@ -1330,6 +1332,7 @@ func newRetributionInfo(chanPoint *wire.OutPoint,
|
|||||||
breachInfo.HtlcRetributions[i].SecondLevelWitnessScript,
|
breachInfo.HtlcRetributions[i].SecondLevelWitnessScript,
|
||||||
&breachInfo.HtlcRetributions[i].SignDesc,
|
&breachInfo.HtlcRetributions[i].SignDesc,
|
||||||
breachInfo.BreachHeight,
|
breachInfo.BreachHeight,
|
||||||
|
breachInfo.HtlcRetributions[i].ResolutionBlob,
|
||||||
)
|
)
|
||||||
|
|
||||||
// For taproot outputs, we also need to hold onto the second
|
// For taproot outputs, we also need to hold onto the second
|
||||||
@ -1636,12 +1639,28 @@ func taprootBriefcaseFromRetInfo(retInfo *retributionInfo) *taprootBriefcase {
|
|||||||
//nolint:lll
|
//nolint:lll
|
||||||
tapCase.CtrlBlocks.Val.CommitSweepCtrlBlock = bo.signDesc.ControlBlock
|
tapCase.CtrlBlocks.Val.CommitSweepCtrlBlock = bo.signDesc.ControlBlock
|
||||||
|
|
||||||
|
bo.resolutionBlob.WhenSome(func(blob tlv.Blob) {
|
||||||
|
tapCase.SettledCommitBlob = tlv.SomeRecordT(
|
||||||
|
tlv.NewPrimitiveRecord[tlv.TlvType2](
|
||||||
|
blob,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
// To spend the revoked output again, we'll store the same
|
// To spend the revoked output again, we'll store the same
|
||||||
// control block value as above, but in a different place.
|
// control block value as above, but in a different place.
|
||||||
case input.TaprootCommitmentRevoke:
|
case input.TaprootCommitmentRevoke:
|
||||||
//nolint:lll
|
//nolint:lll
|
||||||
tapCase.CtrlBlocks.Val.RevokeSweepCtrlBlock = bo.signDesc.ControlBlock
|
tapCase.CtrlBlocks.Val.RevokeSweepCtrlBlock = bo.signDesc.ControlBlock
|
||||||
|
|
||||||
|
bo.resolutionBlob.WhenSome(func(blob tlv.Blob) {
|
||||||
|
tapCase.BreachedCommitBlob = tlv.SomeRecordT(
|
||||||
|
tlv.NewPrimitiveRecord[tlv.TlvType3](
|
||||||
|
blob,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
// For spending the HTLC outputs, we'll store the first and
|
// For spending the HTLC outputs, we'll store the first and
|
||||||
// second level tweak values.
|
// second level tweak values.
|
||||||
case input.TaprootHtlcAcceptedRevoke:
|
case input.TaprootHtlcAcceptedRevoke:
|
||||||
@ -1679,12 +1698,24 @@ func applyTaprootRetInfo(tapCase *taprootBriefcase,
|
|||||||
//nolint:lll
|
//nolint:lll
|
||||||
bo.signDesc.ControlBlock = tapCase.CtrlBlocks.Val.CommitSweepCtrlBlock
|
bo.signDesc.ControlBlock = tapCase.CtrlBlocks.Val.CommitSweepCtrlBlock
|
||||||
|
|
||||||
|
tapCase.SettledCommitBlob.WhenSomeV(
|
||||||
|
func(blob tlv.Blob) {
|
||||||
|
bo.resolutionBlob = fn.Some(blob)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
// To spend the revoked output again, we'll apply the same
|
// To spend the revoked output again, we'll apply the same
|
||||||
// control block value as above, but to a different place.
|
// control block value as above, but to a different place.
|
||||||
case input.TaprootCommitmentRevoke:
|
case input.TaprootCommitmentRevoke:
|
||||||
//nolint:lll
|
//nolint:lll
|
||||||
bo.signDesc.ControlBlock = tapCase.CtrlBlocks.Val.RevokeSweepCtrlBlock
|
bo.signDesc.ControlBlock = tapCase.CtrlBlocks.Val.RevokeSweepCtrlBlock
|
||||||
|
|
||||||
|
tapCase.BreachedCommitBlob.WhenSomeV(
|
||||||
|
func(blob tlv.Blob) {
|
||||||
|
bo.resolutionBlob = fn.Some(blob)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
// For spending the HTLC outputs, we'll apply the first and
|
// For spending the HTLC outputs, we'll apply the first and
|
||||||
// second level tweak values.
|
// second level tweak values.
|
||||||
case input.TaprootHtlcAcceptedRevoke:
|
case input.TaprootHtlcAcceptedRevoke:
|
||||||
|
@ -1199,6 +1199,8 @@ func TestBreachCreateJusticeTx(t *testing.T) {
|
|||||||
input.HtlcSecondLevelRevoke,
|
input.HtlcSecondLevelRevoke,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rBlob := fn.Some([]byte{0x01})
|
||||||
|
|
||||||
breachedOutputs := make([]breachedOutput, len(outputTypes))
|
breachedOutputs := make([]breachedOutput, len(outputTypes))
|
||||||
for i, wt := range outputTypes {
|
for i, wt := range outputTypes {
|
||||||
// Create a fake breached output for each type, ensuring they
|
// Create a fake breached output for each type, ensuring they
|
||||||
@ -1217,6 +1219,7 @@ func TestBreachCreateJusticeTx(t *testing.T) {
|
|||||||
nil,
|
nil,
|
||||||
signDesc,
|
signDesc,
|
||||||
1,
|
1,
|
||||||
|
rBlob,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/lnutils"
|
"github.com/lightningnetwork/lnd/lnutils"
|
||||||
"github.com/lightningnetwork/lnd/lnwallet"
|
"github.com/lightningnetwork/lnd/lnwallet"
|
||||||
"github.com/lightningnetwork/lnd/sweep"
|
"github.com/lightningnetwork/lnd/sweep"
|
||||||
|
"github.com/lightningnetwork/lnd/tlv"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SUMMARY OF OUTPUT STATES
|
// SUMMARY OF OUTPUT STATES
|
||||||
@ -1423,6 +1424,7 @@ func makeKidOutput(outpoint, originChanPoint *wire.OutPoint,
|
|||||||
return kidOutput{
|
return kidOutput{
|
||||||
breachedOutput: makeBreachedOutput(
|
breachedOutput: makeBreachedOutput(
|
||||||
outpoint, witnessType, nil, signDescriptor, heightHint,
|
outpoint, witnessType, nil, signDescriptor, heightHint,
|
||||||
|
fn.None[tlv.Blob](),
|
||||||
),
|
),
|
||||||
isHtlc: isHtlc,
|
isHtlc: isHtlc,
|
||||||
originChanPoint: *originChanPoint,
|
originChanPoint: *originChanPoint,
|
||||||
|
Loading…
Reference in New Issue
Block a user