Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2654,8 +2654,18 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock& locked_chain, const std
CAmount nValue = 0;
int nChangePosRequest = nChangePosInOut;
unsigned int nSubtractFeeFromAmount = 0;
std::set<CTxDestination> destinations;
if (!boost::get<CNoDestination>(&coin_control.destChange)) {
destinations.insert(coin_control.destChange);
}
for (const auto& recipient : vecSend)
{
CTxDestination destination;
if (ExtractDestination(recipient.scriptPubKey, destination) &&
!destinations.insert(destination).second) {
strFailReason = _("Duplicate address found: addresses should only be used once each.");
return false;
}
if (nValue < 0 || recipient.nAmount < 0)
{
strFailReason = _("Transaction amounts must not be negative");
Expand Down
5 changes: 4 additions & 1 deletion test/functional/rpc_fundrawtransaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,14 @@ def run_test(self):
utx = get_unspent(self.nodes[2].listunspent(), 5)

inputs = [ {'txid' : utx['txid'], 'vout' : utx['vout']} ]
outputs = { self.nodes[0].getnewaddress() : Decimal(4.0) }
address = self.nodes[0].getnewaddress()
outputs = { address : Decimal(4.0) }
rawtx = self.nodes[2].createrawtransaction(inputs, outputs)
dec_tx = self.nodes[2].decoderawtransaction(rawtx)
assert_equal(utx['txid'], dec_tx['vin'][0]['txid'])

assert_raises_rpc_error(-4, "Duplicate address found: addresses should only be used once each.", self.nodes[2].fundrawtransaction, rawtx, {'changeAddress':address})

change = self.nodes[2].getnewaddress()
assert_raises_rpc_error(-8, "changePosition out of bounds", self.nodes[2].fundrawtransaction, rawtx, {'changeAddress':change, 'changePosition':2})
rawtxfund = self.nodes[2].fundrawtransaction(rawtx, {'changeAddress': change, 'changePosition': 0})
Expand Down