z_sendmany from a taddr now routes change to a new address instead of back to the sender's taddr,
This commit is contained in:
parent
4876de6c6d
commit
b7d7b2ad9d
|
@ -292,7 +292,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
|||
// Miners fee will be consumed from the value pool
|
||||
fundsSpent += minersFee;
|
||||
|
||||
// Change will flow back to sender address
|
||||
// Private change will flow back to sender's zaddr, while transparent change flows to a new taddr.
|
||||
CAmount change = funds - fundsSpent;
|
||||
if (change < 0)
|
||||
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, strprintf("Insufficient funds or internal error, spent too much leaving negative change %ld", change));
|
||||
|
@ -301,7 +301,16 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
|||
info.vjsout.push_back(JSOutput(frompaymentaddress_, change));
|
||||
} else if (isfromtaddr_) {
|
||||
CMutableTransaction rawTx(tx_);
|
||||
CScript scriptPubKey = GetScriptForDestination(fromtaddr_.Get());
|
||||
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
|
||||
EnsureWalletIsUnlocked();
|
||||
CReserveKey keyChange(pwalletMain);
|
||||
CPubKey vchPubKey;
|
||||
bool ret = keyChange.GetReservedKey(vchPubKey);
|
||||
if (!ret)
|
||||
throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Could not generate a taddr to use as a change address"); // should never fail, as we just unlocked
|
||||
CScript scriptPubKey = GetScriptForDestination(vchPubKey.GetID());
|
||||
CTxOut out(change, scriptPubKey);
|
||||
rawTx.vout.push_back(out);
|
||||
tx_ = CTransaction(rawTx);
|
||||
|
|
|
@ -2870,7 +2870,6 @@ Value z_getoperationstatus(const Array& params, bool fHelp)
|
|||
return status;
|
||||
}
|
||||
|
||||
// If there is any change, it will flow back to the source taddr or zaddr.
|
||||
Value z_sendmany(const Array& params, bool fHelp)
|
||||
{
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
|
@ -2881,6 +2880,7 @@ Value z_sendmany(const Array& params, bool fHelp)
|
|||
"z_sendmany \"fromaddress\" [{\"address\":... ,\"amount\":...},...] ( minconf )\n"
|
||||
"\n*** This alpha release supports multiple recipients, but only one of them can be a zaddr ***"
|
||||
"\nSend multiple times. Amounts are double-precision floating point numbers."
|
||||
"\nChange from a taddr flows to a new taddr address, while change from zaddr returns to itself."
|
||||
+ HelpRequiringPassphrase() + "\n"
|
||||
"\nArguments:\n"
|
||||
"1. \"fromaddress\" (string, required) The taddr or zaddr to send the funds from.\n"
|
||||
|
|
Loading…
Reference in New Issue