Merge rust-bitcoin/rust-bitcoin#2718: bitcoin: Stop slicing hashes
1c836acf30
bitcoin: Stop slicing hashes (Tobin C. Harding) Pull request description: As part of the ongoing effort to improve `hashes`; stop using slicing of hash types and use `as_byte_array()` to get an array reference instead. This gives us more flexability to modify the `hashes` module. ACKs for top commit: apoelstra: ACK1c836acf30
storopoli: ACK1c836acf30
clarkmoody: ACK1c836acf30
Tree-SHA512: ca4becfc9bae13127aae09bd1eb5e03efc670fb4e56c2aba1cf0e3cf5f5a762dd8c5cff8ff7c15167902b7440f70202e0884f1e4d3bb651476019c78d2be3408
This commit is contained in:
commit
16292a8797
|
@ -154,7 +154,7 @@ impl fmt::Display for AddressInner {
|
|||
NetworkKind::Main => PUBKEY_ADDRESS_PREFIX_MAIN,
|
||||
NetworkKind::Test => PUBKEY_ADDRESS_PREFIX_TEST,
|
||||
};
|
||||
prefixed[1..].copy_from_slice(&hash[..]);
|
||||
prefixed[1..].copy_from_slice(hash.as_byte_array());
|
||||
base58::encode_check_to_fmt(fmt, &prefixed[..])
|
||||
}
|
||||
P2sh { hash, network } => {
|
||||
|
@ -163,7 +163,7 @@ impl fmt::Display for AddressInner {
|
|||
NetworkKind::Main => SCRIPT_ADDRESS_PREFIX_MAIN,
|
||||
NetworkKind::Test => SCRIPT_ADDRESS_PREFIX_TEST,
|
||||
};
|
||||
prefixed[1..].copy_from_slice(&hash[..]);
|
||||
prefixed[1..].copy_from_slice(hash.as_byte_array());
|
||||
base58::encode_check_to_fmt(fmt, &prefixed[..])
|
||||
}
|
||||
Segwit { program, hrp } => {
|
||||
|
|
|
@ -818,9 +818,9 @@ impl<R: Borrow<Transaction>> SighashCache<R> {
|
|||
let mut single_enc = LegacySighash::engine();
|
||||
self.tx.borrow().output[input_index].consensus_encode(&mut single_enc)?;
|
||||
let hash = LegacySighash::from_engine(single_enc);
|
||||
writer.write_all(&hash[..])?;
|
||||
writer.write_all(hash.as_byte_array())?;
|
||||
} else {
|
||||
writer.write_all(&zero_hash[..])?;
|
||||
writer.write_all(zero_hash.as_byte_array())?;
|
||||
}
|
||||
|
||||
self.tx.borrow().lock_time.consensus_encode(writer)?;
|
||||
|
|
Loading…
Reference in New Issue