Merge rust-bitcoin/rust-bitcoin#1796: transaction: Rename is_coin_base to is_coinbase

a54e1ceab1 Apply rustfmt (The rustfmt Tyranny)
38d11ce3da ci: Make release CI search for NEXT.RELEASE instead (Steven Roose)
dad3abd20f transaction: Rename is_coin_base to is_coinbase (Steven Roose)

Pull request description:

  Alternative to https://github.com/rust-bitcoin/rust-bitcoin/pull/1795.

  Keep the old method as deprecated and add doc alias. Also change internal usage of the method.

ACKs for top commit:
  tcharding:
    ACK a54e1ceab1
  apoelstra:
    ACK a54e1ceab1

Tree-SHA512: 52d9729bf83da164556d960f8867cb836ff57a0f619da3dd3620efffb28a974aac23b8085863ab0e072a4bdb2f13ac576efa43ad2eec9a271ad044227f4d00a4
This commit is contained in:
Andrew Poelstra 2023-04-24 21:41:10 +00:00
commit 84a075d03a
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
3 changed files with 11 additions and 6 deletions

View File

@ -220,7 +220,7 @@ impl Block {
} }
let coinbase = &self.txdata[0]; let coinbase = &self.txdata[0];
if !coinbase.is_coin_base() { if !coinbase.is_coinbase() {
return false; return false;
} }

View File

@ -981,10 +981,15 @@ impl Transaction {
/// transaction. It is impossible to check if the transaction is first in the block, so this /// 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 /// function checks the structure of the transaction instead - the previous output must be
/// all-zeros (creates satoshis "out of thin air"). /// 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() 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). /// Returns `true` if the transaction itself opted in to be BIP-125-replaceable (RBF).
/// ///
/// # Warning /// # Warning
@ -1578,10 +1583,10 @@ mod tests {
use crate::network::constants::Network; use crate::network::constants::Network;
let genesis = constants::genesis_block(Network::Bitcoin); 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_bytes = hex!("0100000001a15d57094aa7a21a28cb20b59aab8fc7d1149a3bdbcddba9c622e4f5f6a99ece010000006c493046022100f93bb0e7d8db7bd46e40132d1f8242026e045f03a0efe71bbb8e3f475e970d790221009337cd7f1f929f00cc6ff01f03729b069a7c21b59b1736ddfee5db5946c5da8c0121033b9b137ee87d5a812d6f506efdd37f0affa7ffc310711c06c7f3e097c9447c52ffffffff0100e1f505000000001976a9140389035a9225b3839e2bbf32d826a1e222031fd888ac00000000");
let tx: Transaction = deserialize(&tx_bytes).unwrap(); let tx: Transaction = deserialize(&tx_bytes).unwrap();
assert!(!tx.is_coin_base()); assert!(!tx.is_coinbase());
} }
#[test] #[test]

View File

@ -12,9 +12,9 @@ main () {
# Check if there is any mention of NEXT_RELEASE which means the # Check if there is any mention of NEXT_RELEASE which means the
# next version number should be filled in. # next version number should be filled in.
if grep -qr NEXT_RELEASE ./$crate; then if grep -qr NEXT.RELEASE ./$crate; then
echo Version number needs to be filled in following places: echo Version number needs to be filled in following places:
grep -r NEXT_RELEASE ./$crate grep -r NEXT.RELEASE ./$crate
exit 1 exit 1
fi fi