Browse Source

WIP Fix to absurd fee bug on small transaction amounts

We inherited this bug from upstream, and most Zcash forks
probably have similar behavior.

Upstream issue:

https://github.com/zcash/zcash/issues/3281
pull/136/head
Jonathan "Duke" Leto 6 years ago
parent
commit
27654ac111
  1. 20
      src/wallet/rpcwallet.cpp

20
src/wallet/rpcwallet.cpp

@ -3634,8 +3634,10 @@ UniValue z_sendmany(const UniValue& params, bool fHelp)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Minimum number of confirmations cannot be less than 0");
}
// Fee in Zatoshis, not currency format)
CAmount nFee = ASYNC_RPC_OPERATION_DEFAULT_MINERS_FEE;
// Fee in Puposhis, not currency format
CAmount nFee = ASYNC_RPC_OPERATION_DEFAULT_MINERS_FEE;
CAmount nDefaultFee = nFee;
if (params.size() > 3) {
if (params[3].get_real() == 0.0) {
nFee = 0;
@ -3643,9 +3645,17 @@ UniValue z_sendmany(const UniValue& params, bool fHelp)
nFee = AmountFromValue( params[3] );
}
// Check that the user specified fee is sane.
if (nFee > nTotalOut) {
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Fee %s is greater than the sum of outputs %s", FormatMoney(nFee), FormatMoney(nTotalOut)));
// This allows amount=0 (and all amount < nDefaultFee) transactions to use the default network fee
// instead of being forced to use a custom fee and leak metadata
if (nTotalOut < nDefaultFee) {
if (nFee > nDefaultFee) {
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Small transaction amount %s has fee %s that is greater than the default fee %s", FormatMoney(nTotalOut), FormatMoney(nFee), FormatMoney(nDefaultFee)));
}
} else {
// Check that the user specified fee is sane.
if (nFee > nTotalOut) {
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Fee %s is greater than the sum of outputs %s", FormatMoney(nFee), FormatMoney(nTotalOut)));
}
}
}

Loading…
Cancel
Save