zcash_client_backend: Make transparent output indexing resilient
It's cheap to scan all transparent outputs to find the output matching a transparent recipient.
This commit is contained in:
parent
6f93530554
commit
678f1b6734
|
@ -235,10 +235,15 @@ where
|
||||||
Some(idx) => idx,
|
Some(idx) => idx,
|
||||||
None => panic!("Output 0 should exist in the transaction"),
|
None => panic!("Output 0 should exist in the transaction"),
|
||||||
},
|
},
|
||||||
// This function only spends shielded notes, so there will only ever be a single
|
RecipientAddress::Transparent(addr) => {
|
||||||
// transparent output in this case (and even if there were more, we don't shuffle
|
let script = addr.script();
|
||||||
// the transparent outputs).
|
tx.vout
|
||||||
RecipientAddress::Transparent(_) => 0,
|
.iter()
|
||||||
|
.enumerate()
|
||||||
|
.find(|(_, tx_out)| tx_out.script_pubkey == script)
|
||||||
|
.map(|(index, _)| index)
|
||||||
|
.expect("we sent to this address")
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
wallet_db.store_sent_tx(&SentTransaction {
|
wallet_db.store_sent_tx(&SentTransaction {
|
||||||
|
|
Loading…
Reference in New Issue