Use expect for concensus_encode on sinks

Calls to `unwrap` outside of tests are typically unfavourable.

Sink writers do not error. We can use `expect` with a descriptive
message string to indicate this.
This commit is contained in:
Tobin Harding 2021-11-25 10:04:21 +11:00
parent fa513bb5b5
commit 4031fbf4ba
1 changed files with 2 additions and 2 deletions

View File

@ -464,11 +464,11 @@ impl Script {
} else if self.is_witness_program() {
32 + 4 + 1 + (107 / 4) + 4 + // The spend cost copied from Core
8 + // The serialized size of the TxOut's amount field
self.consensus_encode(&mut sink()).unwrap() as u64 // The serialized size of this script_pubkey
self.consensus_encode(&mut sink()).expect("sinks don't error") as u64 // The serialized size of this script_pubkey
} else {
32 + 4 + 1 + 107 + 4 + // The spend cost copied from Core
8 + // The serialized size of the TxOut's amount field
self.consensus_encode(&mut sink()).unwrap() as u64 // The serialized size of this script_pubkey
self.consensus_encode(&mut sink()).expect("sinks don't error") as u64 // The serialized size of this script_pubkey
};
::Amount::from_sat(sats)