watchtower/blob/justice_kit: return DER signatures
This commit fixes an issue with the witness stack construction for to-local and to-remote inputs, that would cause the justice kit to return signatures as fixed-size, 64-byte signatures. The correct behavior is to return DER-encoded signatures so that they will properly verify on the network, since the consensus rules won't be able to understand the fixed-size variant.
This commit is contained in:
1 file changed
+19
-7
@@ -180,12 +180,18 @@ func (b *JusticeKit) CommitToLocalWitnessScript() ([]byte, error) {
|
|||||||
// CommitToLocalRevokeWitnessStack constructs a witness stack spending the
|
// CommitToLocalRevokeWitnessStack constructs a witness stack spending the
|
||||||
// revocation clause of the commitment to-local output.
|
// revocation clause of the commitment to-local output.
|
||||||
// <revocation-sig> 1
|
// <revocation-sig> 1
|
||||||
func (b *JusticeKit) CommitToLocalRevokeWitnessStack() [][]byte {
|
func (b *JusticeKit) CommitToLocalRevokeWitnessStack() ([][]byte, error) {
|
||||||
|
toLocalSig, err := b.CommitToLocalSig.ToSignature()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
witnessStack := make([][]byte, 2)
|
witnessStack := make([][]byte, 2)
|
||||||
witnessStack[0] = append(b.CommitToLocalSig[:], byte(txscript.SigHashAll))
|
witnessStack[0] = append(toLocalSig.Serialize(),
|
||||||
|
byte(txscript.SigHashAll))
|
||||||
witnessStack[1] = []byte{1}
|
witnessStack[1] = []byte{1}
|
||||||
|
|
||||||
return witnessStack
|
return witnessStack, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// HasCommitToRemoteOutput returns true if the blob contains a to-remote p2wkh
|
// HasCommitToRemoteOutput returns true if the blob contains a to-remote p2wkh
|
||||||
@@ -207,11 +213,17 @@ func (b *JusticeKit) CommitToRemoteWitnessScript() ([]byte, error) {
|
|||||||
// CommitToRemoteWitnessStack returns a witness stack spending the commitment
|
// CommitToRemoteWitnessStack returns a witness stack spending the commitment
|
||||||
// to-remote output, which is a regular p2wkh.
|
// to-remote output, which is a regular p2wkh.
|
||||||
// <to-remote-sig>
|
// <to-remote-sig>
|
||||||
func (b *JusticeKit) CommitToRemoteWitnessStack() [][]byte {
|
func (b *JusticeKit) CommitToRemoteWitnessStack() ([][]byte, error) {
|
||||||
witnessStack := make([][]byte, 1)
|
toRemoteSig, err := b.CommitToRemoteSig.ToSignature()
|
||||||
witnessStack[0] = append(b.CommitToRemoteSig[:], byte(txscript.SigHashAll))
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return witnessStack
|
witnessStack := make([][]byte, 1)
|
||||||
|
witnessStack[0] = append(toRemoteSig.Serialize(),
|
||||||
|
byte(txscript.SigHashAll))
|
||||||
|
|
||||||
|
return witnessStack, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encrypt encodes the blob of justice using encoding version, and then
|
// Encrypt encodes the blob of justice using encoding version, and then
|
||||||
|
|||||||
Reference in new issue
Block a user