input: introduce Signature iface

This commit introduces the Signature interface which will be used by our
witness construction methods instead of passing in raw byte slices. This
will be used later to inject various kinds of mock signatures, e.g.
73-byte signatures for simulating worst-case witness weight.
This commit is contained in:
Conner Fromknecht committed 2020-04-09 12:49:11 -07:00
1 parent 2b2c8b5a10
commit 37dffb225a
3 files changed
+37 -11

No files matched your search

+12 -3
View File
@@ -5459,11 +5459,16 @@ func newOutgoingHtlcResolution(signer input.Signer,
InputIndex: 0,
}
htlcSig, err := btcec.ParseDERSignature(htlc.Signature, btcec.S256())
if err != nil {
return nil, err
}
// With the sign desc created, we can now construct the full witness
// for the timeout transaction, and populate it as well.
sigHashType := HtlcSigHashType(chanType)
timeoutWitness, err := input.SenderHtlcSpendTimeout(
htlc.Signature, sigHashType, signer, &timeoutSignDesc, timeoutTx,
htlcSig, sigHashType, signer, &timeoutSignDesc, timeoutTx,
)
if err != nil {
return nil, err
@@ -5585,14 +5590,18 @@ func newIncomingHtlcResolution(signer input.Signer,
InputIndex: 0,
}
htlcSig, err := btcec.ParseDERSignature(htlc.Signature, btcec.S256())
if err != nil {
return nil, err
}
// Next, we'll construct the full witness needed to satisfy the input of
// the success transaction. Don't specify the preimage yet. The preimage
// will be supplied by the contract resolver, either directly or when it
// becomes known.
sigHashType := HtlcSigHashType(chanType)
successWitness, err := input.ReceiverHtlcSpendRedeem(
htlc.Signature, sigHashType, nil, signer, &successSignDesc,
successTx,
htlcSig, sigHashType, nil, signer, &successSignDesc, successTx,
)
if err != nil {
return nil, err