client/clmscript: fix errors in witness size estimation

In this commit, we fix a few lingering errors in witness size
estimation. Both the witness paths were missing a single byte that
signals the number of witness elements. We also convert the OP_DATAs in
the witness script to a varint length, as that more accurately reflects
the way the field is interpreted, as we provide the witness stack as is,
rather than pushing elements onto the stack as if it were a sigScript.
Finally, we add a missing byte for the size of the witness script
itself.
This commit is contained in:
Olaoluwa Osuntokun 2020-03-08 14:59:15 -07:00
parent 6f9ed22e04
commit 369ea2aa8e

View file

@ -34,19 +34,22 @@ const (
AccountWitnessScriptSize = 1 + 33 + 1 + 1 + 33 + 1 + 1 + 1 + 1 + 4 + 1 + 1
// MultiSigWitnessSize: 227 bytes
// - OP_DATA: 1 byte (trader_sig length)
// - num_witness_elements: 1 byte
// - trader_sig_varint_len: 1 byte
// - <trader_sig>: 73 bytes
// - OP_DATA: 1 byte (auctioneer_sig length)
// - auctioneer_sig_varint_len: 1 byte
// - <auctioneer_sig>: 73 bytes
// - witness_script_varint_len: 1 byte
// - <witness_script>: 79 bytes
MultiSigWitnessSize = 1 + 73 + 1 + 73 + AccountWitnessScriptSize
MultiSigWitnessSize = 1 + 1 + 73 + 1 + 73 + 1 + AccountWitnessScriptSize
// ExpiryWitnessSize: 154 bytes
// - OP_DATA: 1 byte (trader_sig length)
// - num_witness_elements: 1 byte
// - trader_sig_varint_len: 1 byte (trader_sig length)
// - <trader_sig>: 73 bytes
// - OP_DATA: 1 byte (nil length)
// - witness_script_varint_len: 1 byte (nil length)
// - <witness_script>: 79 bytes
ExpiryWitnessSize = 1 + 73 + 1 + AccountWitnessScriptSize
ExpiryWitnessSize = 1 + 1 + 73 + 1 + AccountWitnessScriptSize
)
// TraderKeyTweak computes the tweak based on the current per-batch key and