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:
parent
fb4d3909a1
commit
2dd399ca52
@ -180,12 +180,18 @@ func (b *JusticeKit) CommitToLocalWitnessScript() ([]byte, error) {
|
||||
// CommitToLocalRevokeWitnessStack constructs a witness stack spending the
|
||||
// revocation clause of the commitment to-local output.
|
||||
// <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[0] = append(b.CommitToLocalSig[:], byte(txscript.SigHashAll))
|
||||
witnessStack[0] = append(toLocalSig.Serialize(),
|
||||
byte(txscript.SigHashAll))
|
||||
witnessStack[1] = []byte{1}
|
||||
|
||||
return witnessStack
|
||||
return witnessStack, nil
|
||||
}
|
||||
|
||||
// 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
|
||||
// to-remote output, which is a regular p2wkh.
|
||||
// <to-remote-sig>
|
||||
func (b *JusticeKit) CommitToRemoteWitnessStack() [][]byte {
|
||||
witnessStack := make([][]byte, 1)
|
||||
witnessStack[0] = append(b.CommitToRemoteSig[:], byte(txscript.SigHashAll))
|
||||
func (b *JusticeKit) CommitToRemoteWitnessStack() ([][]byte, error) {
|
||||
toRemoteSig, err := b.CommitToRemoteSig.ToSignature()
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user