Skip to content

Commit

Permalink
fix: allow shielded to transparent transfer (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelm41 committed Jul 25, 2024
1 parent febfcf7 commit 7cd10f3
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions ledger-zcash/src/txbuilder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,16 +396,20 @@ impl Builder {
if value != Amount::zero() {
log::debug!("adding output with change");

//avoid having a single output (from the change address) when there are no spends
let change_to_sapling =
if !self.sapling_spends.is_empty() && !self.sapling_outputs.is_empty() {
self.change_address
.clone()
.map(|(ovk, addr)| (Some(ovk), addr))
.or_else(|| self.sapling_spends.get(0).map(|s| (None, s.address())))
} else {
None
};
// avoid having a single output (from the change address) when there are no
// spends
let change_to_sapling = if !self.sapling_spends.is_empty() {
self.change_address
.clone()
.map(|(ovk, addr)| (Some(ovk), addr))
.or_else(|| {
self.sapling_spends
.first()
.map(|s| (None, s.address()))
})
} else {
None
};

if let Some((ovk, addr)) = change_to_sapling {
fee = Self::calculate_zip0317_fee(
Expand Down

0 comments on commit 7cd10f3

Please sign in to comment.