Skip to content

Commit

Permalink
don't, at this time, make mobilecoind start writing 0 value change
Browse files Browse the repository at this point in the history
this should happen at the time of adding RTH support to mobilecoind
  • Loading branch information
cbeck88 committed Apr 21, 2022
1 parent 708956a commit 330f86f
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions mobilecoind/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -988,20 +988,24 @@ impl<T: BlockchainConnection + UserTxConnection + 'static, FPR: FogPubkeyResolve
}
let change = input_value - total_value - tx_builder.get_fee();

// TODO: If you want to support mixed transactions, use outlay-specific token id
// here
let change_amount = Amount {
value: change,
token_id,
};
// TODO: Should the exchange write destination memos?
// If so then we must always write a change output, even if the change is zero
if change > 0 {
// TODO: If you want to support mixed transactions, use outlay-specific token id
// here
let change_amount = Amount {
value: change,
token_id,
};

// If we do, add an output for that as well.
let change_dest =
ChangeDestination::from_subaddress_index(from_account_key, change_subaddress);
// If we do, add an output for that as well.
let change_dest =
ChangeDestination::from_subaddress_index(from_account_key, change_subaddress);

tx_builder
.add_change_output(change_amount, &change_dest, rng)
.map_err(|err| Error::TxBuild(format!("failed adding output (change): {}", err)))?;
tx_builder
.add_change_output(change_amount, &change_dest, rng)
.map_err(|err| Error::TxBuild(format!("failed adding output (change): {}", err)))?;
}

// Set tombstone block.
tx_builder.set_tombstone_block(tombstone_block);
Expand Down

0 comments on commit 330f86f

Please sign in to comment.