diff --git a/zcash_client_sqlite/src/lib.rs b/zcash_client_sqlite/src/lib.rs index 9c1ac261a..01c613c2d 100644 --- a/zcash_client_sqlite/src/lib.rs +++ b/zcash_client_sqlite/src/lib.rs @@ -447,50 +447,51 @@ impl WalletWrite for WalletDb d_tx: DecryptedTransaction, ) -> Result { self.transactionally(|wdb| { - let tx_ref = wallet::put_tx_data(wdb.conn.0, d_tx.tx, None, None)?; + let tx_ref = wallet::put_tx_data(wdb.conn.0, d_tx.tx, None, None)?; - let mut spending_account_id: Option = None; - for output in d_tx.sapling_outputs { - match output.transfer_type { - TransferType::Outgoing | TransferType::WalletInternal => { - let recipient = if output.transfer_type == TransferType::Outgoing { - Recipient::Sapling(output.note.recipient()) - } else { - Recipient::InternalAccount(output.account, PoolType::Sapling) - }; + let mut spending_account_id: Option = None; + for output in d_tx.sapling_outputs { + match output.transfer_type { + TransferType::Outgoing | TransferType::WalletInternal => { + let recipient = if output.transfer_type == TransferType::Outgoing { + Recipient::Sapling(output.note.recipient()) + } else { + Recipient::InternalAccount(output.account, PoolType::Sapling) + }; - wallet::put_sent_output( - wdb.conn.0, - &wdb.params, - output.account, - tx_ref, - output.index, - &recipient, - Amount::from_u64(output.note.value().inner()).map_err(|_| { - SqliteClientError::CorruptedData( - "Note value is not a valid Zcash amount.".to_string(), - ) - })?, - Some(&output.memo), - )?; + wallet::put_sent_output( + wdb.conn.0, + &wdb.params, + output.account, + tx_ref, + output.index, + &recipient, + Amount::from_u64(output.note.value().inner()).map_err(|_| { + SqliteClientError::CorruptedData( + "Note value is not a valid Zcash amount.".to_string(), + ) + })?, + Some(&output.memo), + )?; - if matches!(recipient, Recipient::InternalAccount(_, _)) { - wallet::sapling::put_received_note(wdb.conn.0, output, tx_ref)?; + if matches!(recipient, Recipient::InternalAccount(_, _)) { + wallet::sapling::put_received_note(wdb.conn.0, output, tx_ref)?; + } } - } - TransferType::Incoming => { - match spending_account_id { - Some(id) => { - if id != output.account { - panic!("Unable to determine a unique account identifier for z->t spend."); + TransferType::Incoming => { + match spending_account_id { + Some(id) => { + if id != output.account { + panic!("Unable to determine a unique account identifier for z->t spend."); + } + } + None => { + spending_account_id = Some(output.account); } } - None => { - spending_account_id = Some(output.account); - } - } - wallet::sapling::put_received_note(wdb.conn.0, output, tx_ref)?; + wallet::sapling::put_received_note(wdb.conn.0, output, tx_ref)?; + } } } @@ -527,8 +528,8 @@ impl WalletWrite for WalletDb } } } - } - Ok(tx_ref) + + Ok(tx_ref) }) }