Merge rust-bitcoin/rust-bitcoin#4409: Manual update to rustc (to nightly-2025-05-02)
5ba763f1a2
Update Github CI to rustc nightly-2025-05-02 (Jamil Lambert, PhD)09132b80e1
Fix rustdoc compile_fail example (Jamil Lambert, PhD)282434d4bd
Use variable directly in format! string (Jamil Lambert, PhD)2fbbc825c9
Allow uninlined format args (Jamil Lambert, PhD) Pull request description: There is a new lint error on nightly-2025-04-25 "variables can be used directly in the `format!` string". The existing syntax `format!("{}", x)` is more commonly used than `format!("{x}")` therefore allow it in existing code. Also the rustdoc example in #4259 now causes the new nightly to fail CI because of the unused variable. Patches in the PR: - Exclude the lint to allow the existing syntax in `format!` strings in all crate `lib.rs`, `build.rs.` and test files. - Use the variables in the `format!` string for all cases in `bitcoin/examples/` since there are no other allowed lints in examples. - Correct the function names in the rustdoc example and prefix the unused variable with an underscore. - Update rustc to nightly-2025-05-02 (2025-04-25 had a bug which is fixed in 2025-05-02). ACKs for top commit: apoelstra: ACK 5ba763f1a2ebea2cb80ee50a80228e6bda11936f; successfully ran local tests Kixunil: ACK5ba763f1a2
Tree-SHA512: 20b97d2bedc631715c2b541285559a6ab84bbdb8f2f11d7282bdfecadba0cc8781a1973f0c01c25432aaceaad09e3ddbf59afe54c0bba54768e93ed9d5e50d5a
This commit is contained in:
commit
6adf952b0b
|
@ -21,6 +21,7 @@
|
||||||
// Exclude lints we don't think are valuable.
|
// Exclude lints we don't think are valuable.
|
||||||
#![allow(clippy::needless_question_mark)] // https://github.com/rust-bitcoin/rust-bitcoin/pull/2134
|
#![allow(clippy::needless_question_mark)] // https://github.com/rust-bitcoin/rust-bitcoin/pull/2134
|
||||||
#![allow(clippy::manual_range_contains)] // More readable than clippy's format.
|
#![allow(clippy::manual_range_contains)] // More readable than clippy's format.
|
||||||
|
#![allow(clippy::uninlined_format_args)] // Allow `format!("{}", x)`instead of enforcing `format!("{x}")`
|
||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#![allow(clippy::needless_question_mark)] // https://github.com/rust-bitcoin/rust-bitcoin/pull/2134
|
#![allow(clippy::needless_question_mark)] // https://github.com/rust-bitcoin/rust-bitcoin/pull/2134
|
||||||
#![allow(clippy::manual_range_contains)] // More readable than clippy's format.
|
#![allow(clippy::manual_range_contains)] // More readable than clippy's format.
|
||||||
#![allow(clippy::incompatible_msrv)] // Has FPs and we're testing it which is more reliable anyway.
|
#![allow(clippy::incompatible_msrv)] // Has FPs and we're testing it which is more reliable anyway.
|
||||||
|
#![allow(clippy::uninlined_format_args)] // Allow `format!("{}", x)`instead of enforcing `format!("{x}")`
|
||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
let seed_hex = &args[1];
|
let seed_hex = &args[1];
|
||||||
println!("Seed: {}", seed_hex);
|
println!("Seed: {seed_hex}");
|
||||||
println!("Using mainnet network");
|
println!("Using mainnet network");
|
||||||
|
|
||||||
let seed = Vec::from_hex(seed_hex).unwrap();
|
let seed = Vec::from_hex(seed_hex).unwrap();
|
||||||
|
@ -34,19 +34,19 @@ fn main() {
|
||||||
|
|
||||||
// calculate root key from seed
|
// calculate root key from seed
|
||||||
let root = Xpriv::new_master(NetworkKind::Main, &seed);
|
let root = Xpriv::new_master(NetworkKind::Main, &seed);
|
||||||
println!("Root key: {}", root);
|
println!("Root key: {root}");
|
||||||
|
|
||||||
// derive child xpub
|
// derive child xpub
|
||||||
let path = "84h/0h/0h".parse::<DerivationPath>().unwrap();
|
let path = "84h/0h/0h".parse::<DerivationPath>().unwrap();
|
||||||
let child = root.derive_xpriv(&secp, &path).expect("only deriving three steps");
|
let child = root.derive_xpriv(&secp, &path).expect("only deriving three steps");
|
||||||
println!("Child at {}: {}", path, child);
|
println!("Child at {path}: {child}");
|
||||||
let xpub = Xpub::from_xpriv(&secp, &child);
|
let xpub = Xpub::from_xpriv(&secp, &child);
|
||||||
println!("Public key at {}: {}", path, xpub);
|
println!("Public key at {path}: {xpub}");
|
||||||
|
|
||||||
// generate first receiving address at m/0/0
|
// generate first receiving address at m/0/0
|
||||||
// manually creating indexes this time
|
// manually creating indexes this time
|
||||||
let zero = ChildNumber::ZERO_NORMAL;
|
let zero = ChildNumber::ZERO_NORMAL;
|
||||||
let public_key = xpub.derive_xpub(&secp, &[zero, zero]).unwrap().public_key;
|
let public_key = xpub.derive_xpub(&secp, &[zero, zero]).unwrap().public_key;
|
||||||
let address = Address::p2wpkh(CompressedPublicKey(public_key), KnownHrp::Mainnet);
|
let address = Address::p2wpkh(CompressedPublicKey(public_key), KnownHrp::Mainnet);
|
||||||
println!("First receiving address: {}", address);
|
println!("First receiving address: {address}");
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,6 @@ fn main() {
|
||||||
// Create a Bitcoin P2WPKH address.
|
// Create a Bitcoin P2WPKH address.
|
||||||
let address = Address::p2wpkh(public_key, Network::Bitcoin);
|
let address = Address::p2wpkh(public_key, Network::Bitcoin);
|
||||||
|
|
||||||
println!("Private Key: {}", private_key);
|
println!("Private Key: {private_key}");
|
||||||
println!("Address: {}", address);
|
println!("Address: {address}");
|
||||||
}
|
}
|
||||||
|
|
|
@ -244,8 +244,8 @@ fn main() {
|
||||||
// BOOM! Transaction signed and ready to broadcast.
|
// BOOM! Transaction signed and ready to broadcast.
|
||||||
let signed_tx = psbt.extract_tx().expect("valid transaction");
|
let signed_tx = psbt.extract_tx().expect("valid transaction");
|
||||||
let serialized_signed_tx = consensus::encode::serialize_hex(&signed_tx);
|
let serialized_signed_tx = consensus::encode::serialize_hex(&signed_tx);
|
||||||
println!("Transaction Details: {:#?}", signed_tx);
|
println!("Transaction Details: {signed_tx:#?}");
|
||||||
// check with:
|
// check with:
|
||||||
// bitcoin-cli decoderawtransaction <RAW_TX> true
|
// bitcoin-cli decoderawtransaction <RAW_TX> true
|
||||||
println!("Raw Transaction: {}", serialized_signed_tx);
|
println!("Raw Transaction: {serialized_signed_tx}");
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ fn main() -> Result<()> {
|
||||||
tx.verify(|_| Some(previous_output())).expect("failed to verify transaction");
|
tx.verify(|_| Some(previous_output())).expect("failed to verify transaction");
|
||||||
|
|
||||||
let hex = encode::serialize_hex(&tx);
|
let hex = encode::serialize_hex(&tx);
|
||||||
println!("You should now be able to broadcast the following transaction: \n\n{}", hex);
|
println!("You should now be able to broadcast the following transaction: \n\n{hex}");
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ fn main() {
|
||||||
let str_address = &args[1];
|
let str_address = &args[1];
|
||||||
|
|
||||||
let address: SocketAddr = str_address.parse().unwrap_or_else(|error| {
|
let address: SocketAddr = str_address.parse().unwrap_or_else(|error| {
|
||||||
eprintln!("error parsing address: {:?}", error);
|
eprintln!("error parsing address: {error:?}");
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -22,14 +22,14 @@ fn main() {
|
||||||
assert_eq!(decoded, script_code);
|
assert_eq!(decoded, script_code);
|
||||||
|
|
||||||
// Writes the script as human-readable eg, OP_DUP OP_HASH160 OP_PUSHBYTES_20 ...
|
// Writes the script as human-readable eg, OP_DUP OP_HASH160 OP_PUSHBYTES_20 ...
|
||||||
println!("human-readable script: {}", script_code);
|
println!("human-readable script: {script_code}");
|
||||||
|
|
||||||
// We do not implement parsing scripts from human-readable format.
|
// We do not implement parsing scripts from human-readable format.
|
||||||
// let decoded = s.parse::<ScriptBuf>().unwrap();
|
// let decoded = s.parse::<ScriptBuf>().unwrap();
|
||||||
|
|
||||||
// This is equivalent to consensus encoding i.e., includes the length prefix.
|
// This is equivalent to consensus encoding i.e., includes the length prefix.
|
||||||
let hex_lower_hex_trait = format!("{:x}", script_code);
|
let hex_lower_hex_trait = format!("{script_code:x}");
|
||||||
println!("hex created using `LowerHex`: {}", hex_lower_hex_trait);
|
println!("hex created using `LowerHex`: {hex_lower_hex_trait}");
|
||||||
|
|
||||||
// The `deserialize_hex` function requires the length prefix.
|
// The `deserialize_hex` function requires the length prefix.
|
||||||
assert_eq!(encode::deserialize_hex::<ScriptBuf>(&hex_lower_hex_trait).unwrap(), script_code);
|
assert_eq!(encode::deserialize_hex::<ScriptBuf>(&hex_lower_hex_trait).unwrap(), script_code);
|
||||||
|
@ -43,7 +43,7 @@ fn main() {
|
||||||
|
|
||||||
// This is consensus encoding i.e., includes the length prefix.
|
// This is consensus encoding i.e., includes the length prefix.
|
||||||
let hex_inherent = script_code.to_hex_string(); // Defined in `ScriptExt`.
|
let hex_inherent = script_code.to_hex_string(); // Defined in `ScriptExt`.
|
||||||
println!("hex created using inherent `to_hex_string`: {}", hex_inherent);
|
println!("hex created using inherent `to_hex_string`: {hex_inherent}");
|
||||||
|
|
||||||
// The inverse of `to_hex_string` is `from_hex`.
|
// The inverse of `to_hex_string` is `from_hex`.
|
||||||
let decoded = ScriptBuf::from_hex(&hex_inherent).unwrap(); // Defined in `ScriptBufExt`.
|
let decoded = ScriptBuf::from_hex(&hex_inherent).unwrap(); // Defined in `ScriptBufExt`.
|
||||||
|
@ -54,7 +54,7 @@ fn main() {
|
||||||
|
|
||||||
// We also support encode/decode using `consensus::encode` functions.
|
// We also support encode/decode using `consensus::encode` functions.
|
||||||
let encoded = encode::serialize_hex(&script_code);
|
let encoded = encode::serialize_hex(&script_code);
|
||||||
println!("hex created using consensus::encode::serialize_hex: {}", encoded);
|
println!("hex created using consensus::encode::serialize_hex: {encoded}");
|
||||||
|
|
||||||
let decoded: ScriptBuf = encode::deserialize_hex(&encoded).unwrap();
|
let decoded: ScriptBuf = encode::deserialize_hex(&encoded).unwrap();
|
||||||
assert_eq!(decoded, script_code);
|
assert_eq!(decoded, script_code);
|
||||||
|
|
|
@ -24,7 +24,7 @@ fn compute_sighash_p2wpkh(raw_tx: &[u8], inp_idx: usize, amount: Amount) {
|
||||||
let tx: Transaction = consensus::deserialize(raw_tx).unwrap();
|
let tx: Transaction = consensus::deserialize(raw_tx).unwrap();
|
||||||
let inp = &tx.input[inp_idx];
|
let inp = &tx.input[inp_idx];
|
||||||
let witness = &inp.witness;
|
let witness = &inp.witness;
|
||||||
println!("Witness: {:?}", witness);
|
println!("Witness: {witness:?}");
|
||||||
|
|
||||||
// BIP-141: The witness must consist of exactly 2 items (≤ 520 bytes each). The first one a
|
// BIP-141: The witness must consist of exactly 2 items (≤ 520 bytes each). The first one a
|
||||||
// signature, and the second one a public key.
|
// signature, and the second one a public key.
|
||||||
|
@ -38,16 +38,16 @@ fn compute_sighash_p2wpkh(raw_tx: &[u8], inp_idx: usize, amount: Amount) {
|
||||||
//this is nothing but a standard P2PKH script OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG:
|
//this is nothing but a standard P2PKH script OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG:
|
||||||
let pk = CompressedPublicKey::from_slice(pk_bytes).expect("failed to parse pubkey");
|
let pk = CompressedPublicKey::from_slice(pk_bytes).expect("failed to parse pubkey");
|
||||||
let wpkh = pk.wpubkey_hash();
|
let wpkh = pk.wpubkey_hash();
|
||||||
println!("Script pubkey hash: {:x}", wpkh);
|
println!("Script pubkey hash: {wpkh:x}");
|
||||||
let spk = ScriptBuf::new_p2wpkh(wpkh);
|
let spk = ScriptBuf::new_p2wpkh(wpkh);
|
||||||
|
|
||||||
let mut cache = sighash::SighashCache::new(&tx);
|
let mut cache = sighash::SighashCache::new(&tx);
|
||||||
let sighash = cache
|
let sighash = cache
|
||||||
.p2wpkh_signature_hash(inp_idx, &spk, amount, sig.sighash_type)
|
.p2wpkh_signature_hash(inp_idx, &spk, amount, sig.sighash_type)
|
||||||
.expect("failed to compute sighash");
|
.expect("failed to compute sighash");
|
||||||
println!("SegWit p2wpkh sighash: {:x}", sighash);
|
println!("SegWit p2wpkh sighash: {sighash:x}");
|
||||||
let msg = secp256k1::Message::from(sighash);
|
let msg = secp256k1::Message::from(sighash);
|
||||||
println!("Message is {:x}", msg);
|
println!("Message is {msg:x}");
|
||||||
let secp = secp256k1::Secp256k1::verification_only();
|
let secp = secp256k1::Secp256k1::verification_only();
|
||||||
pk.verify(&secp, msg, sig).unwrap()
|
pk.verify(&secp, msg, sig).unwrap()
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ fn compute_sighash_legacy(raw_tx: &[u8], inp_idx: usize, script_pubkey_bytes_opt
|
||||||
let tx: Transaction = consensus::deserialize(raw_tx).unwrap();
|
let tx: Transaction = consensus::deserialize(raw_tx).unwrap();
|
||||||
let inp = &tx.input[inp_idx];
|
let inp = &tx.input[inp_idx];
|
||||||
let script_sig = &inp.script_sig;
|
let script_sig = &inp.script_sig;
|
||||||
println!("scriptSig is: {}", script_sig);
|
println!("scriptSig is: {script_sig}");
|
||||||
let cache = sighash::SighashCache::new(&tx);
|
let cache = sighash::SighashCache::new(&tx);
|
||||||
//In the P2SH case we get scriptPubKey from scriptSig of the spending input.
|
//In the P2SH case we get scriptPubKey from scriptSig of the spending input.
|
||||||
//The scriptSig that corresponds to an M of N multisig should be: PUSHBYTES_0 PUSHBYTES_K0 <sig0><sighashflag0> ... PUSHBYTES_Km <sigM><sighashflagM> PUSHBYTES_X <scriptPubKey>
|
//The scriptSig that corresponds to an M of N multisig should be: PUSHBYTES_0 PUSHBYTES_K0 <sig0><sighashflag0> ... PUSHBYTES_Km <sigM><sighashflagM> PUSHBYTES_X <scriptPubKey>
|
||||||
|
@ -83,8 +83,7 @@ fn compute_sighash_legacy(raw_tx: &[u8], inp_idx: usize, script_pubkey_bytes_opt
|
||||||
let pushbytes_0 = instructions.remove(0).unwrap();
|
let pushbytes_0 = instructions.remove(0).unwrap();
|
||||||
assert!(
|
assert!(
|
||||||
pushbytes_0.push_bytes().unwrap().as_bytes().is_empty(),
|
pushbytes_0.push_bytes().unwrap().as_bytes().is_empty(),
|
||||||
"first in ScriptSig must be PUSHBYTES_0 got {:?}",
|
"first in ScriptSig must be PUSHBYTES_0 got {pushbytes_0:?}"
|
||||||
pushbytes_0
|
|
||||||
);
|
);
|
||||||
|
|
||||||
//All other scriptSig instructions must be signatures
|
//All other scriptSig instructions must be signatures
|
||||||
|
@ -109,7 +108,7 @@ fn compute_sighash_p2wsh(raw_tx: &[u8], inp_idx: usize, amount: Amount) {
|
||||||
let tx: Transaction = consensus::deserialize(raw_tx).unwrap();
|
let tx: Transaction = consensus::deserialize(raw_tx).unwrap();
|
||||||
let inp = &tx.input[inp_idx];
|
let inp = &tx.input[inp_idx];
|
||||||
let witness = &inp.witness;
|
let witness = &inp.witness;
|
||||||
println!("witness {:?}", witness);
|
println!("witness {witness:?}");
|
||||||
|
|
||||||
//last element is called witnessScript according to BIP141. It supersedes scriptPubKey.
|
//last element is called witnessScript according to BIP141. It supersedes scriptPubKey.
|
||||||
let witness_script_bytes: &[u8] = witness.last().expect("out of bounds");
|
let witness_script_bytes: &[u8] = witness.last().expect("out of bounds");
|
||||||
|
@ -122,7 +121,7 @@ fn compute_sighash_p2wsh(raw_tx: &[u8], inp_idx: usize, amount: Amount) {
|
||||||
let sig = ecdsa::Signature::from_slice(sig_bytes).expect("failed to parse sig");
|
let sig = ecdsa::Signature::from_slice(sig_bytes).expect("failed to parse sig");
|
||||||
let sig_len = sig_bytes.len() - 1; //last byte is EcdsaSighashType sighash flag
|
let sig_len = sig_bytes.len() - 1; //last byte is EcdsaSighashType sighash flag
|
||||||
//ECDSA signature in DER format lengths are between 70 and 72 bytes
|
//ECDSA signature in DER format lengths are between 70 and 72 bytes
|
||||||
assert!((70..=72).contains(&sig_len), "signature length {} out of bounds", sig_len);
|
assert!((70..=72).contains(&sig_len), "signature length {sig_len} out of bounds");
|
||||||
//here we assume that all sighash_flags are the same. Can they be different?
|
//here we assume that all sighash_flags are the same. Can they be different?
|
||||||
let sighash = cache
|
let sighash = cache
|
||||||
.p2wsh_signature_hash(inp_idx, witness_script, amount, sig.sighash_type)
|
.p2wsh_signature_hash(inp_idx, witness_script, amount, sig.sighash_type)
|
||||||
|
|
|
@ -82,7 +82,7 @@ fn main() {
|
||||||
let tx = sighasher.into_transaction();
|
let tx = sighasher.into_transaction();
|
||||||
|
|
||||||
// BOOM! Transaction signed and ready to broadcast.
|
// BOOM! Transaction signed and ready to broadcast.
|
||||||
println!("{:#?}", tx);
|
println!("{tx:#?}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An example of keys controlled by the transaction sender.
|
/// An example of keys controlled by the transaction sender.
|
||||||
|
|
|
@ -81,7 +81,7 @@ fn main() {
|
||||||
let tx = sighasher.into_transaction();
|
let tx = sighasher.into_transaction();
|
||||||
|
|
||||||
// BOOM! Transaction signed and ready to broadcast.
|
// BOOM! Transaction signed and ready to broadcast.
|
||||||
println!("{:#?}", tx);
|
println!("{tx:#?}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An example of keys controlled by the transaction sender.
|
/// An example of keys controlled by the transaction sender.
|
||||||
|
|
|
@ -244,8 +244,8 @@ fn main() {
|
||||||
// BOOM! Transaction signed and ready to broadcast.
|
// BOOM! Transaction signed and ready to broadcast.
|
||||||
let signed_tx = psbt.extract_tx().expect("valid transaction");
|
let signed_tx = psbt.extract_tx().expect("valid transaction");
|
||||||
let serialized_signed_tx = consensus::encode::serialize_hex(&signed_tx);
|
let serialized_signed_tx = consensus::encode::serialize_hex(&signed_tx);
|
||||||
println!("Transaction Details: {:#?}", signed_tx);
|
println!("Transaction Details: {signed_tx:#?}");
|
||||||
// check with:
|
// check with:
|
||||||
// bitcoin-cli decoderawtransaction <RAW_TX> true
|
// bitcoin-cli decoderawtransaction <RAW_TX> true
|
||||||
println!("Raw Transaction: {}", serialized_signed_tx);
|
println!("Raw Transaction: {serialized_signed_tx}");
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,8 +125,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
],
|
],
|
||||||
)?);
|
)?);
|
||||||
println!(
|
println!(
|
||||||
"\nYou should now be able to broadcast the following transaction: \n\n{}",
|
"\nYou should now be able to broadcast the following transaction: \n\n{tx_hex_string}"
|
||||||
tx_hex_string
|
|
||||||
);
|
);
|
||||||
|
|
||||||
println!("\nEND EXAMPLE 1\n");
|
println!("\nEND EXAMPLE 1\n");
|
||||||
|
@ -147,7 +146,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
)?;
|
)?;
|
||||||
let tx_hex = encode::serialize_hex(&tx);
|
let tx_hex = encode::serialize_hex(&tx);
|
||||||
|
|
||||||
println!("Inheritance funding tx hex:\n\n{}", tx_hex);
|
println!("Inheritance funding tx hex:\n\n{tx_hex}");
|
||||||
// You can now broadcast the transaction hex:
|
// You can now broadcast the transaction hex:
|
||||||
// bt sendrawtransaction ...
|
// bt sendrawtransaction ...
|
||||||
//
|
//
|
||||||
|
@ -160,7 +159,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
to_address,
|
to_address,
|
||||||
)?;
|
)?;
|
||||||
let spending_tx_hex = encode::serialize_hex(&spending_tx);
|
let spending_tx_hex = encode::serialize_hex(&spending_tx);
|
||||||
println!("\nInheritance spending tx hex:\n\n{}", spending_tx_hex);
|
println!("\nInheritance spending tx hex:\n\n{spending_tx_hex}");
|
||||||
// If you try to broadcast now, the transaction will be rejected as it is timelocked.
|
// If you try to broadcast now, the transaction will be rejected as it is timelocked.
|
||||||
// First mine 900 blocks so we're sure we are over the 1000 block locktime:
|
// First mine 900 blocks so we're sure we are over the 1000 block locktime:
|
||||||
// bt generatetoaddress 900 $(bt-benefactor getnewaddress '' 'bech32m')
|
// bt generatetoaddress 900 $(bt-benefactor getnewaddress '' 'bech32m')
|
||||||
|
@ -185,7 +184,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
)?;
|
)?;
|
||||||
let tx_hex = encode::serialize_hex(&tx);
|
let tx_hex = encode::serialize_hex(&tx);
|
||||||
|
|
||||||
println!("Inheritance funding tx hex:\n\n{}", tx_hex);
|
println!("Inheritance funding tx hex:\n\n{tx_hex}");
|
||||||
// You can now broadcast the transaction hex:
|
// You can now broadcast the transaction hex:
|
||||||
// bt sendrawtransaction ...
|
// bt sendrawtransaction ...
|
||||||
//
|
//
|
||||||
|
@ -200,7 +199,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let (tx, _) = benefactor.refresh_tx(1000)?;
|
let (tx, _) = benefactor.refresh_tx(1000)?;
|
||||||
let tx_hex = encode::serialize_hex(&tx);
|
let tx_hex = encode::serialize_hex(&tx);
|
||||||
|
|
||||||
println!("\nRefreshed inheritance tx hex:\n\n{}\n", tx_hex);
|
println!("\nRefreshed inheritance tx hex:\n\n{tx_hex}\n");
|
||||||
|
|
||||||
println!("\nEND EXAMPLE 3\n");
|
println!("\nEND EXAMPLE 3\n");
|
||||||
println!("----------------\n");
|
println!("----------------\n");
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#![allow(clippy::needless_question_mark)] // https://github.com/rust-bitcoin/rust-bitcoin/pull/2134
|
#![allow(clippy::needless_question_mark)] // https://github.com/rust-bitcoin/rust-bitcoin/pull/2134
|
||||||
#![allow(clippy::manual_range_contains)] // More readable than clippy's format.
|
#![allow(clippy::manual_range_contains)] // More readable than clippy's format.
|
||||||
#![allow(clippy::incompatible_msrv)] // Has FPs and we're testing it which is more reliable anyway.
|
#![allow(clippy::incompatible_msrv)] // Has FPs and we're testing it which is more reliable anyway.
|
||||||
|
#![allow(clippy::uninlined_format_args)] // Allow `format!("{}", x)`instead of enforcing `format!("{x}")`
|
||||||
|
|
||||||
// We only support machines with index size of 4 bytes or more.
|
// We only support machines with index size of 4 bytes or more.
|
||||||
//
|
//
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
// Exclude lints we don't think are valuable.
|
// Exclude lints we don't think are valuable.
|
||||||
#![allow(clippy::needless_question_mark)] // https://github.com/rust-bitcoin/rust-bitcoin/pull/2134
|
#![allow(clippy::needless_question_mark)] // https://github.com/rust-bitcoin/rust-bitcoin/pull/2134
|
||||||
#![allow(clippy::manual_range_contains)] // More readable than clippy's format.
|
#![allow(clippy::manual_range_contains)] // More readable than clippy's format.
|
||||||
|
#![allow(clippy::uninlined_format_args)] // Allow `format!("{}", x)`instead of enforcing `format!("{x}")`
|
||||||
|
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
// Exclude lints we don't think are valuable.
|
// Exclude lints we don't think are valuable.
|
||||||
#![allow(clippy::needless_question_mark)] // https://github.com/rust-bitcoin/rust-bitcoin/pull/2134
|
#![allow(clippy::needless_question_mark)] // https://github.com/rust-bitcoin/rust-bitcoin/pull/2134
|
||||||
#![allow(clippy::manual_range_contains)] // More readable than clippy's format.
|
#![allow(clippy::manual_range_contains)] // More readable than clippy's format.
|
||||||
|
#![allow(clippy::uninlined_format_args)] // Allow `format!("{}", x)`instead of enforcing `format!("{x}")`
|
||||||
|
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
|
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
#![allow(unused_imports)]
|
#![allow(unused_imports)]
|
||||||
|
// Exclude lints we don't think are valuable.
|
||||||
|
#![allow(clippy::uninlined_format_args)] // Allow `format!("{}", x)`instead of enforcing `format!("{x}")`
|
||||||
|
|
||||||
// Import using module style e.g., `sha256::Hash`.
|
// Import using module style e.g., `sha256::Hash`.
|
||||||
use bitcoin_hashes::{
|
use bitcoin_hashes::{
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
//! Test input data and expected hashes is the same as in `io/src/hash.rs`.
|
//! Test input data and expected hashes is the same as in `io/src/hash.rs`.
|
||||||
|
|
||||||
#![cfg(feature = "hex")]
|
#![cfg(feature = "hex")]
|
||||||
|
// Exclude lints we don't think are valuable.
|
||||||
|
#![allow(clippy::uninlined_format_args)] // Allow `format!("{}", x)`instead of enforcing `format!("{x}")`
|
||||||
|
|
||||||
use bitcoin_hashes::{
|
use bitcoin_hashes::{
|
||||||
hash160, ripemd160, sha1, sha256, sha256d, sha256t, sha384, sha512, sha512_256, siphash24,
|
hash160, ripemd160, sha1, sha256, sha256d, sha256t, sha384, sha512, sha512_256, siphash24,
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
// Exclude lints we don't think are valuable.
|
||||||
|
#![allow(clippy::uninlined_format_args)] // Allow `format!("{}", x)`instead of enforcing `format!("{x}")`
|
||||||
|
|
||||||
const MAX_USED_VERSION: u64 = 80;
|
const MAX_USED_VERSION: u64 = 80;
|
||||||
|
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
// Exclude lints we don't think are valuable.
|
// Exclude lints we don't think are valuable.
|
||||||
#![allow(clippy::needless_question_mark)] // https://github.com/rust-bitcoin/rust-bitcoin/pull/2134
|
#![allow(clippy::needless_question_mark)] // https://github.com/rust-bitcoin/rust-bitcoin/pull/2134
|
||||||
#![allow(clippy::manual_range_contains)] // More readable than clippy's format.
|
#![allow(clippy::manual_range_contains)] // More readable than clippy's format.
|
||||||
|
#![allow(clippy::uninlined_format_args)] // Allow `format!("{}", x)`instead of enforcing `format!("{x}")`
|
||||||
|
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
|
@ -10,8 +10,9 @@ pub trait SliceExt {
|
||||||
/// Note that `N` must not be zero:
|
/// Note that `N` must not be zero:
|
||||||
///
|
///
|
||||||
/// ```compile_fail
|
/// ```compile_fail
|
||||||
|
/// # use bitcoin_internals::slice::SliceExt;
|
||||||
/// let slice = [1, 2, 3];
|
/// let slice = [1, 2, 3];
|
||||||
/// let fail = slice.as_chunks::<0>();
|
/// let _fail = slice.bitcoin_as_chunks::<0>();
|
||||||
/// ```
|
/// ```
|
||||||
fn bitcoin_as_chunks<const N: usize>(&self) -> (&[[Self::Item; N]], &[Self::Item]);
|
fn bitcoin_as_chunks<const N: usize>(&self) -> (&[[Self::Item; N]], &[Self::Item]);
|
||||||
|
|
||||||
|
@ -20,8 +21,9 @@ pub trait SliceExt {
|
||||||
/// Note that `N` must not be zero:
|
/// Note that `N` must not be zero:
|
||||||
///
|
///
|
||||||
/// ```compile_fail
|
/// ```compile_fail
|
||||||
|
/// # use bitcoin_internals::slice::SliceExt;
|
||||||
/// let mut slice = [1, 2, 3];
|
/// let mut slice = [1, 2, 3];
|
||||||
/// let fail = slice.as_chunks_mut::<0>();
|
/// let _fail = slice.bitcoin_as_chunks_mut::<0>();
|
||||||
/// ```
|
/// ```
|
||||||
fn bitcoin_as_chunks_mut<const N: usize>(
|
fn bitcoin_as_chunks_mut<const N: usize>(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
// Exclude lints we don't think are valuable.
|
// Exclude lints we don't think are valuable.
|
||||||
#![allow(clippy::needless_question_mark)] // https://github.com/rust-bitcoin/rust-bitcoin/pull/2134
|
#![allow(clippy::needless_question_mark)] // https://github.com/rust-bitcoin/rust-bitcoin/pull/2134
|
||||||
#![allow(clippy::manual_range_contains)] // More readable than clippy's format.
|
#![allow(clippy::manual_range_contains)] // More readable than clippy's format.
|
||||||
|
#![allow(clippy::uninlined_format_args)] // Allow `format!("{}", x)`instead of enforcing `format!("{x}")`
|
||||||
|
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
nightly-2025-04-11
|
nightly-2025-05-02
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
#![warn(missing_docs)]
|
#![warn(missing_docs)]
|
||||||
#![warn(deprecated_in_future)]
|
#![warn(deprecated_in_future)]
|
||||||
#![doc(test(attr(warn(unused))))]
|
#![doc(test(attr(warn(unused))))]
|
||||||
|
// Exclude lints we don't think are valuable.
|
||||||
|
#![allow(clippy::uninlined_format_args)] // Allow `format!("{}", x)`instead of enforcing `format!("{x}")`
|
||||||
|
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
#![warn(missing_docs)]
|
#![warn(missing_docs)]
|
||||||
#![warn(deprecated_in_future)]
|
#![warn(deprecated_in_future)]
|
||||||
#![doc(test(attr(warn(unused))))]
|
#![doc(test(attr(warn(unused))))]
|
||||||
|
// Exclude lints we don't think are valuable.
|
||||||
|
#![allow(clippy::uninlined_format_args)] // Allow `format!("{}", x)`instead of enforcing `format!("{x}")`
|
||||||
|
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
Loading…
Reference in New Issue