Coin selection with small amounts fix (#2144)

* coin selection fix for sending with an amount <= smallest output

* rustfmt
This commit is contained in:
Yeastplume 2018-12-13 11:19:46 +00:00 committed by GitHub
parent 793e3843f0
commit df62fd6d95
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View file

@ -48,8 +48,9 @@ impl WalletCommAdapter for HTTPWalletCommAdapter {
let url = format!("{}/v1/wallet/foreign/receive_tx", dest);
debug!("Posting transaction slate to {}", url);
let res = api::client::post(url.as_str(), None, slate)
.context(ErrorKind::ClientCallback("Posting transaction slate"))?;
let res = api::client::post(url.as_str(), None, slate).context(
ErrorKind::ClientCallback("Posting transaction slate (is recipient listening?)"),
)?;
Ok(res)
}

View file

@ -235,7 +235,7 @@ where
K: Keychain,
{
// select some spendable coins from the wallet
let (max_outputs, coins) = select_coins(
let (max_outputs, mut coins) = select_coins(
wallet,
amount,
current_height,
@ -291,7 +291,7 @@ where
}
// select some spendable coins from the wallet
let (_, coins) = select_coins(
coins = select_coins(
wallet,
amount_with_fee,
current_height,
@ -299,7 +299,8 @@ where
max_outputs,
selection_strategy_is_use_all,
parent_key_id,
);
)
.1;
fee = tx_fee(coins.len(), num_outputs, 1, None);
total = coins.iter().map(|c| c.value).sum();
amount_with_fee = amount + fee;