lnwallet: implement special case for OP_RETURN in rbf-coop
In this commit, we implement a special case for OP_RETURN scripts outlined in the spec. If a party decides that its output will be too small even after the dust check, then they can opt to set it to zero by sending an `OP_RETURN` as their script.
This commit is contained in:
1 parent
e6d7a1a2ec
commit
333492e657
2 files changed
+85
-4
No files matched your search
+18
-4
@@ -9269,13 +9269,19 @@ func CreateCooperativeCloseTx(fundingTxIn wire.TxIn,
|
||||
closeTx.LockTime = lockTime
|
||||
})
|
||||
|
||||
// TODO(roasbeef): needs support for dropping inputs
|
||||
|
||||
// Create both cooperative closure outputs, properly respecting the
|
||||
// dust limits of both parties.
|
||||
// Create both cooperative closure outputs, properly respecting the dust
|
||||
// limits of both parties.
|
||||
var localOutputIdx fn.Option[int]
|
||||
haveLocalOutput := ourBalance >= localDust
|
||||
if haveLocalOutput {
|
||||
// If our script is an OP_RETURN, then we set our balance to
|
||||
// zero.
|
||||
if opts.customSequence.IsSome() &&
|
||||
input.ScriptIsOpReturn(ourDeliveryScript) {
|
||||
|
||||
ourBalance = 0
|
||||
}
|
||||
|
||||
closeTx.AddTxOut(&wire.TxOut{
|
||||
PkScript: ourDeliveryScript,
|
||||
Value: int64(ourBalance),
|
||||
@@ -9287,6 +9293,14 @@ func CreateCooperativeCloseTx(fundingTxIn wire.TxIn,
|
||||
var remoteOutputIdx fn.Option[int]
|
||||
haveRemoteOutput := theirBalance >= remoteDust
|
||||
if haveRemoteOutput {
|
||||
// If a party's script is an OP_RETURN, then we set their
|
||||
// balance to zero.
|
||||
if opts.customSequence.IsSome() &&
|
||||
input.ScriptIsOpReturn(theirDeliveryScript) {
|
||||
|
||||
theirBalance = 0
|
||||
}
|
||||
|
||||
closeTx.AddTxOut(&wire.TxOut{
|
||||
PkScript: theirDeliveryScript,
|
||||
Value: int64(theirBalance),
|
||||
|
||||
Reference in new issue
Block a user