Skip to content

Commit

Permalink
Fixes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
altafan committed Dec 18, 2023
1 parent fa77100 commit 71a69c2
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pkg/wallet/single-sig/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,8 @@ func (w *Wallet) signTaprootInput(
return err
}
input := ptx.Inputs[inIndex]
if input.SigHashType == 0 {
if err := signer.AddInSighashType(inIndex, sighashType); err != nil {
return err
}
if err := signer.AddInSighashType(inIndex, sighashType); err != nil {
return err
}

prvkey, pubkey, err := w.DeriveSigningKeyPair(DeriveSigningKeyPairArgs{
Expand Down Expand Up @@ -412,10 +410,15 @@ func signTaproot(
return nil, fmt.Errorf("signature verification failed for input %d", inIndex)
}

sig := signature.Serialize()
if sighashType != txscript.SigHashDefault {
sig = append(sig, byte(sighashType))
}

return &psetv2.TapScriptSig{
PartialSig: psetv2.PartialSig{
PubKey: schnorr.SerializePubKey(pubkey),
Signature: signature.Serialize(),
Signature: sig,
},
}, nil
}

0 comments on commit 71a69c2

Please sign in to comment.