From 0e529ba4cdd3d225ae842a2d81c7a16514a35433 Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Sat, 19 Oct 2019 20:21:34 -0700 Subject: [PATCH] Fix crash when insufficient funds --- lib/src/lightwallet/data.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/src/lightwallet/data.rs b/lib/src/lightwallet/data.rs index 8660f5d..38128ca 100644 --- a/lib/src/lightwallet/data.rs +++ b/lib/src/lightwallet/data.rs @@ -490,7 +490,8 @@ pub struct SpendableNote { impl SpendableNote { pub fn from(txid: TxId, nd: &SaplingNoteData, anchor_offset: usize, extsk: &ExtendedSpendingKey) -> Option { // Include only notes that haven't been spent, or haven't been included in an unconfirmed spend yet. - if nd.spent.is_none() && nd.unconfirmed_spent.is_none() { + if nd.spent.is_none() && nd.unconfirmed_spent.is_none() && + nd.witnesses.len() >= (anchor_offset + 1) { let witness = nd.witnesses.get(nd.witnesses.len() - anchor_offset - 1); witness.map(|w| SpendableNote {