Merge rust-bitcoin/rust-bitcoin#952: Remove MSRV todo comments
831b0267de
Use contains() instead of manual range (Tobin C. Harding)6410095687
Use chunks_exact (Tobin C. Harding)3a0097ba49
Use trim_start_matches (Tobin C. Harding)0a19710906
Use vec! macro instead of new followed by push (Tobin C. Harding) Pull request description: Now that 0.28 is out we do not need to support Rust 1.29 on `master`. Remove trivial MSRV `TODO`s from the code. (All these changes only rely on MSRV bumping to 1.31 so are easily within bounds.) ACKs for top commit: Kixunil: ACK831b0267de
sanket1729: ACK831b0267de
Tree-SHA512: f1ea594216ba7dfa24696b964ce296a8aea72dd2e16e11d3a43fe8b90c851abf59b1612b2b1311146e8070112f3834762584e4f0515b8f546f72af169eb4bda9
This commit is contained in:
commit
e47d89c537
|
@ -651,7 +651,7 @@ impl fmt::Debug for All {
|
|||
all::OP_CHECKMULTISIGVERIFY => write!(f, "CHECKMULTISIGVERIFY"),
|
||||
all::OP_CLTV => write!(f, "CLTV"),
|
||||
all::OP_CSV => write!(f, "CSV"),
|
||||
All {code: x} if x >= all::OP_NOP1.code && x <= all::OP_NOP10.code => write!(f, "NOP{}", x - all::OP_NOP1.code + 1),
|
||||
All {code: x} if (all::OP_NOP1.code..=all::OP_NOP10.code).contains(&x) => write!(f, "NOP{}", x - all::OP_NOP1.code + 1),
|
||||
all::OP_INVALIDOPCODE => write!(f, "INVALIDOPCODE"),
|
||||
all::OP_CHECKSIGADD => write!(f, "CHECKSIGADD"),
|
||||
All {code: x} => write!(f, "RETURN_{}", x),
|
||||
|
|
|
@ -1208,18 +1208,13 @@ mod tests {
|
|||
#[test]
|
||||
fn sighash_single_bug() {
|
||||
const SIGHASH_SINGLE: u32 = 3;
|
||||
// We need a tx with more inputs than outputs.
|
||||
let mut input = Vec::new();
|
||||
input.push(TxIn::default());
|
||||
input.push(TxIn::default());
|
||||
let mut output = Vec::new();
|
||||
output.push(TxOut::default());
|
||||
|
||||
// We need a tx with more inputs than outputs.
|
||||
let tx = Transaction {
|
||||
version: 1,
|
||||
lock_time: 0,
|
||||
input: input,
|
||||
output: output, // TODO: Use Vec::from([TxOut]) once we bump MSRV.
|
||||
input: vec![TxIn::default(), TxIn::default()],
|
||||
output: vec![TxOut::default()],
|
||||
};
|
||||
let script = Script::new();
|
||||
let got = tx.signature_hash(1, &script, SIGHASH_SINGLE);
|
||||
|
|
|
@ -166,7 +166,6 @@ impl fmt::Display for PsbtSighashType {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(deprecated)] // TODO: Swap `trim_left_matches` for `trim_start_matches` once MSRV >= 1.30.
|
||||
impl FromStr for PsbtSighashType {
|
||||
type Err = SighashTypeParseError;
|
||||
|
||||
|
@ -184,7 +183,7 @@ impl FromStr for PsbtSighashType {
|
|||
}
|
||||
|
||||
// We accept non-standard sighash values.
|
||||
if let Ok(inner) = u32::from_str_radix(s.trim_left_matches("0x"), 16) {
|
||||
if let Ok(inner) = u32::from_str_radix(s.trim_start_matches("0x"), 16) {
|
||||
return Ok(PsbtSighashType { inner });
|
||||
}
|
||||
|
||||
|
|
|
@ -683,13 +683,13 @@ impl TaprootMerkleBranch {
|
|||
Err(TaprootError::InvalidMerkleTreeDepth(sl.len() / TAPROOT_CONTROL_NODE_SIZE))
|
||||
} else {
|
||||
let inner = sl
|
||||
// TODO: Use chunks_exact after MSRV changes to 1.31
|
||||
.chunks(TAPROOT_CONTROL_NODE_SIZE)
|
||||
.chunks_exact(TAPROOT_CONTROL_NODE_SIZE)
|
||||
.map(|chunk| {
|
||||
sha256::Hash::from_slice(chunk)
|
||||
.expect("chunk exact always returns the correct size")
|
||||
.expect("chunks_exact always returns the correct size")
|
||||
})
|
||||
.collect();
|
||||
|
||||
Ok(TaprootMerkleBranch(inner))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue