Skip to content

Commit bfd5ccc

Browse files
canndrewknocte
authored andcommitted
Add revocation ability to CommitmentToLocalExtension
1 parent 6062c26 commit bfd5ccc

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/DotNetLightning.Core/Channel/CommitmentToLocalExtension.fs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ open ResultUtils
1010
open ResultUtils.Portability
1111

1212
type CommitmentToLocalParameters = {
13+
RevocationPubKey: RevocationPubKey
1314
ToSelfDelay: BlockHeightOffset16
1415
LocalDelayedPubKey: DelayedPaymentPubKey
1516
}
@@ -33,7 +34,7 @@ type CommitmentToLocalParameters = {
3334
SeqParser.parseToCompletion ops <| seqParser {
3435
do! checkOpCode OpcodeType.OP_IF
3536
let! opRevocationPubKey = SeqParser.next()
36-
let! _revocationPubKey = seqParser {
37+
let! revocationPubKey = seqParser {
3738
match opRevocationPubKey.PushData with
3839
| null -> return! SeqParser.abort()
3940
| bytes ->
@@ -69,6 +70,7 @@ type CommitmentToLocalParameters = {
6970
do! checkOpCode OpcodeType.OP_ENDIF
7071
do! checkOpCode OpcodeType.OP_CHECKSIG
7172
return {
73+
RevocationPubKey = revocationPubKey
7274
ToSelfDelay = toSelfDelay
7375
LocalDelayedPubKey = localDelayedPubKey
7476
}
@@ -96,6 +98,12 @@ type internal CommitmentToLocalExtension() =
9698
// could not be generated.
9799
match pubKey with
98100
| null -> null
101+
| _ when pubKey = parameters.RevocationPubKey.RawPubKey() ->
102+
let revocationSig = signer.Sign (parameters.RevocationPubKey.RawPubKey())
103+
Script [
104+
Op.GetPushOp (revocationSig.ToBytes())
105+
Op.op_Implicit OpcodeType.OP_TRUE
106+
]
99107
| _ when pubKey = parameters.LocalDelayedPubKey.RawPubKey() ->
100108
let localDelayedSig = signer.Sign (parameters.LocalDelayedPubKey.RawPubKey())
101109
Script [
@@ -125,6 +133,8 @@ type internal CommitmentToLocalExtension() =
125133
override self.IsCompatibleKey(pubKey: PubKey, scriptPubKey: Script): bool =
126134
match CommitmentToLocalParameters.TryExtractParameters scriptPubKey with
127135
| None -> false
128-
| Some parameters -> parameters.LocalDelayedPubKey.RawPubKey() = pubKey
136+
| Some parameters ->
137+
parameters.RevocationPubKey.RawPubKey() = pubKey
138+
|| parameters.LocalDelayedPubKey.RawPubKey() = pubKey
129139

130140

0 commit comments

Comments
 (0)