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:
parent
fa513bb5b5
commit
4031fbf4ba
|
@ -464,11 +464,11 @@ impl Script {
|
||||||
} else if self.is_witness_program() {
|
} else if self.is_witness_program() {
|
||||||
32 + 4 + 1 + (107 / 4) + 4 + // The spend cost copied from Core
|
32 + 4 + 1 + (107 / 4) + 4 + // The spend cost copied from Core
|
||||||
8 + // The serialized size of the TxOut's amount field
|
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 {
|
} else {
|
||||||
32 + 4 + 1 + 107 + 4 + // The spend cost copied from Core
|
32 + 4 + 1 + 107 + 4 + // The spend cost copied from Core
|
||||||
8 + // The serialized size of the TxOut's amount field
|
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)
|
::Amount::from_sat(sats)
|
||||||
|
|
Loading…
Reference in New Issue