diff --git a/libtonode-tests/tests/concrete.rs b/libtonode-tests/tests/concrete.rs index 66cf6c1fb..1c9d07cfc 100644 --- a/libtonode-tests/tests/concrete.rs +++ b/libtonode-tests/tests/concrete.rs @@ -1225,6 +1225,7 @@ mod fast { .unwrap(); faucet.quick_shield().await.unwrap(); } + #[ignore = "requires 100 blocks to be generated to shield coinbase. wait for zebrad integration."] #[tokio::test] async fn mine_to_transparent_and_propose_shielding() { let regtest_network = RegtestNetwork::all_upgrades_active(); @@ -1257,6 +1258,7 @@ mod fast { NonNegativeAmount::const_from_u64((block_rewards::CANOPY * 4) - expected_fee) ) } + #[ignore = "requires 100 blocks to be generated to shield coinbase. wait for zebrad integration."] #[tokio::test] async fn mine_to_transparent_and_propose_shielding_with_div_addr() { let regtest_network = RegtestNetwork::all_upgrades_active(); diff --git a/zingolib/src/wallet/disk.rs b/zingolib/src/wallet/disk.rs index e9ec96b6b..2060398a4 100644 --- a/zingolib/src/wallet/disk.rs +++ b/zingolib/src/wallet/disk.rs @@ -38,10 +38,10 @@ use super::{ }; impl LightWallet { - /// Changes in version 30: - /// - New WalletCapability version (v4) which implements read/write for rejection addresses + /// Changes in version 31: + /// - Added `is_coinbase` bool to transparent outputs pub const fn serialized_version() -> u64 { - 30 + 31 } /// TODO: Add Doc Comment Here! diff --git a/zingolib/src/wallet/notes/transparent.rs b/zingolib/src/wallet/notes/transparent.rs index b87dc3757..18748bb27 100644 --- a/zingolib/src/wallet/notes/transparent.rs +++ b/zingolib/src/wallet/notes/transparent.rs @@ -25,9 +25,10 @@ pub struct TransparentOutput { pub script: Vec, /// TODO: Add Doc Comment Here! pub value: u64, - /// whether, where, and when it was spent spend: Option<(TxId, ConfirmationStatus)>, + /// Output is from a coinbase transaction + pub is_coinbase: bool, } impl OutputInterface for TransparentOutput { @@ -85,6 +86,7 @@ impl TransparentOutput { script: Vec, value: u64, spend: Option<(TxId, ConfirmationStatus)>, + is_coinbase: bool, ) -> Self { Self { address, @@ -93,6 +95,7 @@ impl TransparentOutput { script, value, spend, + is_coinbase, } } @@ -103,7 +106,7 @@ impl TransparentOutput { /// write + read pub fn serialized_version() -> u64 { - 4 + 5 } /// TODO: Add Doc Comment Here! @@ -137,6 +140,8 @@ impl TransparentOutput { w.write_i32::(s) })?; + writer.write_u8(self.is_coinbase as u8)?; + Ok(()) } @@ -202,6 +207,12 @@ impl TransparentOutput { let spend = spent_tuple.map(|(txid, height)| (txid, ConfirmationStatus::Confirmed(height.into()))); + let is_coinbase = if version >= 5 { + reader.read_u8()? != 0 + } else { + false + }; + Ok(TransparentOutput { address, txid: transaction_id, @@ -209,6 +220,7 @@ impl TransparentOutput { script, value, spend, + is_coinbase, }) } } @@ -261,6 +273,7 @@ pub mod mocks { self.script.clone().unwrap(), self.value.unwrap(), self.spending_tx_status.unwrap(), + false, ) } } diff --git a/zingolib/src/wallet/transaction_context.rs b/zingolib/src/wallet/transaction_context.rs index afbc3781d..dc4fb2242 100644 --- a/zingolib/src/wallet/transaction_context.rs +++ b/zingolib/src/wallet/transaction_context.rs @@ -218,6 +218,7 @@ mod decrypt_transaction { /// This method records that receipt in the relevant receiving /// TransactionRecord in the TransactionRecordsById database. + #[allow(clippy::too_many_arguments)] async fn record_taddr_receipt( &self, transaction: &zcash_primitives::transaction::Transaction, @@ -226,6 +227,7 @@ mod decrypt_transaction { block_time: Option, vout: &zcash_primitives::transaction::components::TxOut, n: usize, + is_coinbase: bool, ) { self.transaction_metadata_set .write() @@ -238,6 +240,7 @@ mod decrypt_transaction { block_time, vout, n as u32, + is_coinbase, ); } /// New value has been detected for one of the wallet's transparent @@ -250,6 +253,8 @@ mod decrypt_transaction { block_time: Option, ) { if let Some(t_bundle) = transaction.transparent_bundle() { + let is_coinbase = t_bundle.is_coinbase(); + // Collect our t-addresses for easy checking // the get_taddrs method includes ephemeral 320 taddrs let taddrs_set = self.key.get_taddrs(&self.config.chain); @@ -264,6 +269,7 @@ mod decrypt_transaction { block_time, vout, n, + is_coinbase, ) .await; } diff --git a/zingolib/src/wallet/transaction_record.rs b/zingolib/src/wallet/transaction_record.rs index 29b27960a..3190c1fae 100644 --- a/zingolib/src/wallet/transaction_record.rs +++ b/zingolib/src/wallet/transaction_record.rs @@ -496,7 +496,7 @@ impl TransactionRecord { /// TODO: Add Doc Comment Here! pub fn serialized_version() -> u64 { - 24 + 25 } /// TODO: Add Doc Comment Here! diff --git a/zingolib/src/wallet/transaction_records_by_id.rs b/zingolib/src/wallet/transaction_records_by_id.rs index 678b438d6..f24e3949b 100644 --- a/zingolib/src/wallet/transaction_records_by_id.rs +++ b/zingolib/src/wallet/transaction_records_by_id.rs @@ -672,6 +672,7 @@ impl TransactionRecordsById { timestamp: Option, vout: &zcash_primitives::transaction::components::TxOut, output_num: u32, + is_coinbase: bool, ) { // Read or create the current TxId let transaction_metadata = @@ -693,6 +694,7 @@ impl TransactionRecordsById { vout.script_pubkey.0.clone(), u64::from(vout.value), None, + is_coinbase, ), ); } diff --git a/zingolib/src/wallet/transaction_records_by_id/trait_inputsource.rs b/zingolib/src/wallet/transaction_records_by_id/trait_inputsource.rs index 08d8db4c1..7521ec8ac 100644 --- a/zingolib/src/wallet/transaction_records_by_id/trait_inputsource.rs +++ b/zingolib/src/wallet/transaction_records_by_id/trait_inputsource.rs @@ -303,7 +303,17 @@ impl InputSource for TransactionRecordsById { }) .flat_map(|tx| { tx.transparent_outputs().iter().filter_map(|output| { - if output.spending_tx_status().is_none() + let mature = if output.is_coinbase { + tx.status + .get_confirmed_height() + .expect("transaction should be confirmed") + <= target_height - 100 + } else { + true + }; + + if mature + && output.spending_tx_status().is_none() && (output.address == address.encode(&zcash_primitives::consensus::MAIN_NETWORK) || output.address diff --git a/zingolib/src/wallet/tx_map/read_write.rs b/zingolib/src/wallet/tx_map/read_write.rs index f332db550..c066b5e2c 100644 --- a/zingolib/src/wallet/tx_map/read_write.rs +++ b/zingolib/src/wallet/tx_map/read_write.rs @@ -17,7 +17,7 @@ use super::{spending_data::SpendingData, TransactionRecordsById, TxMap}; impl TxMap { /// TODO: Doc-comment! pub fn serialized_version() -> u64 { - 22 + 23 } /// TODO: Doc-comment!