Auto merge of #2068 - bitcartel:2045_sendmany_fee_zero, r=bitcartel

Closes #2045 by allowing z_sendmany with 0 fee
This commit is contained in:
zkbot 2017-02-09 18:56:44 +00:00
commit b2e2dccc64
3 changed files with 20 additions and 2 deletions

View File

@ -140,6 +140,19 @@ class WalletProtectCoinbaseTest (BitcoinTestFramework):
assert_equal(Decimal(resp["private"]), Decimal('19.9999'))
assert_equal(Decimal(resp["total"]), Decimal('39.9999'))
# A custom fee of 0 is okay. Here the node will send the note value back to itself.
recipients = []
recipients.append({"address":myzaddr, "amount": Decimal('19.9999')})
myopid = self.nodes[0].z_sendmany(myzaddr, recipients, 1, Decimal('0.0'))
mytxid = self.wait_and_assert_operationid_status(myopid)
self.sync_all()
self.nodes[1].generate(1)
self.sync_all()
resp = self.nodes[0].z_gettotalbalance()
assert_equal(Decimal(resp["transparent"]), Decimal('20.0'))
assert_equal(Decimal(resp["private"]), Decimal('19.9999'))
assert_equal(Decimal(resp["total"]), Decimal('39.9999'))
# convert note to transparent funds
recipients = []
recipients.append({"address":mytaddr, "amount":Decimal('10.0')})

View File

@ -55,7 +55,7 @@ AsyncRPCOperation_sendmany::AsyncRPCOperation_sendmany(
Value contextInfo) :
fromaddress_(fromAddress), t_outputs_(tOutputs), z_outputs_(zOutputs), mindepth_(minDepth), fee_(fee), contextinfo_(contextInfo)
{
assert(fee_ > 0);
assert(fee_ >= 0);
if (minDepth < 0) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Minconf cannot be negative");

View File

@ -3385,7 +3385,12 @@ Value z_sendmany(const Array& params, bool fHelp)
// Fee in Zatoshis, not currency format)
CAmount nFee = ASYNC_RPC_OPERATION_DEFAULT_MINERS_FEE;
if (params.size() > 3) {
nFee = AmountFromValue( params[3] );
if (params[3].get_real() == 0.0) {
nFee = 0;
} else {
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)));