Figure out the account ID for z->t spends.
This commit is contained in:
parent
13cd7498b7
commit
665c4c7aff
|
@ -206,7 +206,6 @@ pub struct PrunedBlock<'a> {
|
||||||
/// wallet database when transactions are successfully decrypted.
|
/// wallet database when transactions are successfully decrypted.
|
||||||
pub struct DecryptedTransaction<'a> {
|
pub struct DecryptedTransaction<'a> {
|
||||||
pub tx: &'a Transaction,
|
pub tx: &'a Transaction,
|
||||||
pub account_id: AccountId,
|
|
||||||
pub sapling_outputs: &'a Vec<DecryptedOutput>,
|
pub sapling_outputs: &'a Vec<DecryptedOutput>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,6 @@ where
|
||||||
if !(sapling_outputs.is_empty() && tx.vout.is_empty()) {
|
if !(sapling_outputs.is_empty() && tx.vout.is_empty()) {
|
||||||
data.store_decrypted_tx(&DecryptedTransaction {
|
data.store_decrypted_tx(&DecryptedTransaction {
|
||||||
tx,
|
tx,
|
||||||
account_id: AccountId(0), //FIXME
|
|
||||||
sapling_outputs: &sapling_outputs,
|
sapling_outputs: &sapling_outputs,
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
|
|
|
@ -521,6 +521,7 @@ impl<'a, P: consensus::Parameters> WalletWrite for DataConnStmtCache<'a, P> {
|
||||||
self.transactionally(|up| {
|
self.transactionally(|up| {
|
||||||
let tx_ref = wallet::put_tx_data(up, d_tx.tx, None)?;
|
let tx_ref = wallet::put_tx_data(up, d_tx.tx, None)?;
|
||||||
|
|
||||||
|
let mut spending_account_id: Option<AccountId> = None;
|
||||||
for output in d_tx.sapling_outputs {
|
for output in d_tx.sapling_outputs {
|
||||||
if output.outgoing {
|
if output.outgoing {
|
||||||
wallet::put_sent_note(
|
wallet::put_sent_note(
|
||||||
|
@ -529,12 +530,21 @@ impl<'a, P: consensus::Parameters> WalletWrite for DataConnStmtCache<'a, P> {
|
||||||
output.index,
|
output.index,
|
||||||
output.account,
|
output.account,
|
||||||
RecipientAddress::Shielded(output.to.clone()),
|
RecipientAddress::Shielded(output.to.clone()),
|
||||||
Amount::from_u64(output.note.value).map_err(|_| {
|
Amount::from_u64(output.note.value)
|
||||||
SqliteClientError::CorruptedData("Note value invalid.".to_string())
|
.map_err(|_| SqliteClientError::CorruptedData("Note value invalid.".to_string()))?,
|
||||||
})?,
|
|
||||||
Some(&output.memo),
|
Some(&output.memo),
|
||||||
)?;
|
)?;
|
||||||
} else {
|
} else {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
wallet::put_received_note(up, output, tx_ref)?;
|
wallet::put_received_note(up, output, tx_ref)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -544,19 +554,21 @@ impl<'a, P: consensus::Parameters> WalletWrite for DataConnStmtCache<'a, P> {
|
||||||
// as our z->t tx and store the vouts as our sent notes.
|
// as our z->t tx and store the vouts as our sent notes.
|
||||||
// FIXME this is a weird heuristic that is bound to trip us up somewhere.
|
// FIXME this is a weird heuristic that is bound to trip us up somewhere.
|
||||||
if d_tx.sapling_outputs.iter().any(|output| !output.outgoing) {
|
if d_tx.sapling_outputs.iter().any(|output| !output.outgoing) {
|
||||||
|
if let Some(account_id) = spending_account_id {
|
||||||
for (i, txout) in d_tx.tx.vout.iter().enumerate() {
|
for (i, txout) in d_tx.tx.vout.iter().enumerate() {
|
||||||
// FIXME: We shouldn't be confusing notes and transparent outputs.
|
// FIXME: We shouldn't be confusing notes and transparent outputs.
|
||||||
wallet::insert_sent_note(
|
wallet::put_sent_note(
|
||||||
up,
|
up,
|
||||||
tx_ref,
|
tx_ref,
|
||||||
i,
|
i,
|
||||||
d_tx.account_id,
|
account_id,
|
||||||
&RecipientAddress::Transparent(txout.script_pubkey.address().unwrap()),
|
RecipientAddress::Transparent(txout.script_pubkey.address().unwrap()),
|
||||||
txout.value,
|
txout.value,
|
||||||
None,
|
None,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(tx_ref)
|
Ok(tx_ref)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue