Apply suggestions from code review

Co-authored-by: str4d <thestr4d@gmail.com>
This commit is contained in:
Kris Nuttycombe 2022-03-10 21:43:35 -07:00 committed by Kris Nuttycombe
parent 5d17e53c5c
commit 30dd633de6
2 changed files with 5 additions and 6 deletions

View File

@ -100,7 +100,7 @@ typedef void (*push_spend_action_idx_callback_t)(void* rec, uint32_t actionIdx);
* Searches the provided bundle for notes that are visible to the specified wallet's
* incoming viewing keys, and adds those notes to the wallet. For each note decryptable
* by one of the wallet's keys, this method will insert a `RawOrchardActionIVK` value into
* the provided `decryptedActionIVKs` referent using the `push_cb` callback. Note that
* the provided `callbackReceiver` referent using the `push_cb` callback. Note that
* this callback can perform transformations on the provided RawOrchardActionIVK in this
* process. For each action spending one of the wallet's notes, this method will insert
* a `uint32_t` action index into the `spendingActionIdxs` referent.

View File

@ -372,9 +372,9 @@ impl Wallet {
/// Restore note and potential spend data from a bundle using the provided
/// metadata.
///
/// - `tx_height`: if the transaction containing the bundle has been mined,
/// - `tx_height`: if the transaction containing the bundle has been mined,
/// this should contain the block height it was mined at
/// - `txid`: The ID for the transaction from which the provided bundle was
/// - `txid`: The ID for the transaction from which the provided bundle was
/// extracted.
/// - `bundle`: the bundle to decrypt notes from
/// - `hints`: a map from action index to the incoming viewing key that decrypts
@ -773,18 +773,17 @@ pub extern "C" fn orchard_wallet_add_notes_from_bundle(
let txid = TxId::from_bytes(*unsafe { txid.as_ref() }.expect("txid may not be null."));
if let Some(bundle) = unsafe { bundle.as_ref() } {
let added = wallet.add_notes_from_bundle(&txid, bundle);
let mut involved = false;
let involved =
!(added.receive_action_metadata.is_empty() && added.spend_action_metadata.is_empty());
for (action_idx, ivk) in added.receive_action_metadata.into_iter() {
let action_ivk = FFIActionIvk {
action_idx: action_idx.try_into().unwrap(),
ivk_ptr: Box::into_raw(Box::new(ivk.clone())),
};
unsafe { (action_ivk_push_cb.unwrap())(cb_receiver, action_ivk) };
involved = true;
}
for action_idx in added.spend_action_metadata {
unsafe { (spend_idx_push_cb.unwrap())(cb_receiver, action_idx.try_into().unwrap()) };
involved = true;
}
involved
} else {