From dad3abd20fe7bca8bfe56827e43f56f5c23bdb6a Mon Sep 17 00:00:00 2001 From: Steven Roose Date: Thu, 13 Apr 2023 04:24:38 +0100 Subject: [PATCH] transaction: Rename is_coin_base to is_coinbase Keep the old method as deprecated and add doc alias. Also change internal usage of the method. --- bitcoin/src/blockdata/block.rs | 2 +- bitcoin/src/blockdata/transaction.rs | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/bitcoin/src/blockdata/block.rs b/bitcoin/src/blockdata/block.rs index 5641625f..0065903f 100644 --- a/bitcoin/src/blockdata/block.rs +++ b/bitcoin/src/blockdata/block.rs @@ -220,7 +220,7 @@ impl Block { } let coinbase = &self.txdata[0]; - if !coinbase.is_coin_base() { + if !coinbase.is_coinbase() { return false; } diff --git a/bitcoin/src/blockdata/transaction.rs b/bitcoin/src/blockdata/transaction.rs index c87c5698..0465a3ed 100644 --- a/bitcoin/src/blockdata/transaction.rs +++ b/bitcoin/src/blockdata/transaction.rs @@ -981,10 +981,17 @@ impl Transaction { /// transaction. It is impossible to check if the transaction is first in the block, so this /// function checks the structure of the transaction instead - the previous output must be /// all-zeros (creates satoshis "out of thin air"). - pub fn is_coin_base(&self) -> bool { + #[doc(alias = "is_coin_base")] // method previously had this name + pub fn is_coinbase(&self) -> bool { self.input.len() == 1 && self.input[0].previous_output.is_null() } + /// Checks if this is a coinbase transaction. + #[deprecated(since = "0.0.0-NEXT_RELEASE", note = "use is_coinbase instead")] + pub fn is_coin_base(&self) -> bool { + self.is_coinbase() + } + /// Returns `true` if the transaction itself opted in to be BIP-125-replaceable (RBF). /// /// # Warning @@ -1548,10 +1555,10 @@ mod tests { use crate::network::constants::Network; let genesis = constants::genesis_block(Network::Bitcoin); - assert!(genesis.txdata[0].is_coin_base()); + assert!(genesis.txdata[0].is_coinbase()); let tx_bytes = hex!("0100000001a15d57094aa7a21a28cb20b59aab8fc7d1149a3bdbcddba9c622e4f5f6a99ece010000006c493046022100f93bb0e7d8db7bd46e40132d1f8242026e045f03a0efe71bbb8e3f475e970d790221009337cd7f1f929f00cc6ff01f03729b069a7c21b59b1736ddfee5db5946c5da8c0121033b9b137ee87d5a812d6f506efdd37f0affa7ffc310711c06c7f3e097c9447c52ffffffff0100e1f505000000001976a9140389035a9225b3839e2bbf32d826a1e222031fd888ac00000000"); let tx: Transaction = deserialize(&tx_bytes).unwrap(); - assert!(!tx.is_coin_base()); + assert!(!tx.is_coinbase()); } #[test]