diff --git a/src/builder.rs b/src/builder.rs index 4229cbb28..9dfaa9efb 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -387,7 +387,7 @@ impl Builder { // Pair up the spends and recipients, extending with dummy values as necessary. for (asset, (mut spends, mut recipients)) in - partition_by_asset(&self.spends, &self.recipients) + partition_by_asset(&self.spends, &self.recipients, &mut rng) { let num_spends = spends.len(); let num_recipients = recipients.len(); @@ -475,10 +475,12 @@ impl Builder { } } -/// partition a list of spends and recipients by note types. +/// Partition a list of spends and recipients by note types. +/// Method creates single dummy ZEC note if spends and recipients are both empty. fn partition_by_asset( spends: &[SpendInfo], recipients: &[RecipientInfo], + rng: &mut impl RngCore, ) -> HashMap, Vec)> { let mut hm = HashMap::new(); @@ -496,6 +498,11 @@ fn partition_by_asset( .push(r.clone()) } + if hm.is_empty() { + let dummy_spend = SpendInfo::dummy(AssetId::native(), rng); + hm.insert(dummy_spend.note.asset(), (vec![dummy_spend], vec![])); + } + hm }