Merge pull request #360 from nuttycom/fix/225_no_change_spends

Retrieve nullifiers for all unconfirmed notes.
This commit is contained in:
str4d 2021-03-25 17:31:41 +13:00 committed by GitHub
commit 863be19a21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -470,13 +470,21 @@ pub fn get_witnesses<P>(
Ok(res)
}
/// Retrieve the nullifiers for notes that the wallet is tracking
/// that have not yet been confirmed as a consequence of the spending
/// transaction being included in a block.
pub fn get_nullifiers<P>(
wdb: &WalletDB<P>,
) -> Result<Vec<(AccountId, Nullifier)>, SqliteClientError> {
// Get the nullifiers for the notes we are tracking
let mut stmt_fetch_nullifiers = wdb
.conn
.prepare("SELECT id_note, account, nf FROM received_notes WHERE spent IS NULL")?;
.prepare(
"SELECT rn.id_note, rn.account, rn.nf, tx.block as block
FROM received_notes rn
LEFT OUTER JOIN transactions tx
ON tx.id_tx = rn.spent
WHERE block IS NULL")?;
let nullifiers = stmt_fetch_nullifiers.query_map(NO_PARAMS, |row| {
let account = AccountId(row.get(1)?);
let nf_bytes: Vec<u8> = row.get(2)?;