Do not use deprecated function in rustdoc example

Currently we are use the deprecated signing method on `Transaction`, we
should use the new method on the sighash cache.
This commit is contained in:
Tobin C. Harding 2023-02-07 14:17:03 +11:00
parent 98130f49f1
commit e38d843536
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 4 additions and 2 deletions

View File

@ -589,8 +589,9 @@ impl<E> EncodeSigningDataResult<E> {
/// ```rust /// ```rust
/// # use bitcoin::consensus::deserialize; /// # use bitcoin::consensus::deserialize;
/// # use bitcoin::Transaction; /// # use bitcoin::Transaction;
/// # use bitcoin::hash_types::Sighash; /// # use bitcoin::crypto::sighash::SighashCache;
/// # use bitcoin_hashes::{Hash, hex::FromHex}; /// # use bitcoin_hashes::{Hash, hex::FromHex};
/// # use bitcoin::hash_types::Sighash;
/// # let mut writer = Sighash::engine(); /// # let mut writer = Sighash::engine();
/// # let input_index = 0; /// # let input_index = 0;
/// # let script_pubkey = bitcoin::ScriptBuf::new(); /// # let script_pubkey = bitcoin::ScriptBuf::new();
@ -598,7 +599,8 @@ impl<E> EncodeSigningDataResult<E> {
/// # const SOME_TX: &'static str = "0100000001a15d57094aa7a21a28cb20b59aab8fc7d1149a3bdbcddba9c622e4f5f6a99ece010000006c493046022100f93bb0e7d8db7bd46e40132d1f8242026e045f03a0efe71bbb8e3f475e970d790221009337cd7f1f929f00cc6ff01f03729b069a7c21b59b1736ddfee5db5946c5da8c0121033b9b137ee87d5a812d6f506efdd37f0affa7ffc310711c06c7f3e097c9447c52ffffffff0100e1f505000000001976a9140389035a9225b3839e2bbf32d826a1e222031fd888ac00000000"; /// # const SOME_TX: &'static str = "0100000001a15d57094aa7a21a28cb20b59aab8fc7d1149a3bdbcddba9c622e4f5f6a99ece010000006c493046022100f93bb0e7d8db7bd46e40132d1f8242026e045f03a0efe71bbb8e3f475e970d790221009337cd7f1f929f00cc6ff01f03729b069a7c21b59b1736ddfee5db5946c5da8c0121033b9b137ee87d5a812d6f506efdd37f0affa7ffc310711c06c7f3e097c9447c52ffffffff0100e1f505000000001976a9140389035a9225b3839e2bbf32d826a1e222031fd888ac00000000";
/// # let raw_tx = Vec::from_hex(SOME_TX).unwrap(); /// # let raw_tx = Vec::from_hex(SOME_TX).unwrap();
/// # let tx: Transaction = deserialize(&raw_tx).unwrap(); /// # let tx: Transaction = deserialize(&raw_tx).unwrap();
/// if tx.encode_signing_data_to(&mut writer, input_index, &script_pubkey, sighash_u32) /// # let cache = SighashCache::new(&tx);
/// if cache.legacy_encode_signing_data_to(&mut writer, input_index, &script_pubkey, sighash_u32)
/// .is_sighash_single_bug() /// .is_sighash_single_bug()
/// .expect("writer can't fail") { /// .expect("writer can't fail") {
/// // use a hash value of "1", instead of computing the actual hash due to SIGHASH_SINGLE bug /// // use a hash value of "1", instead of computing the actual hash due to SIGHASH_SINGLE bug