mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-02-04 06:12:07 +01:00
[Wallet] unset change position when there is no change on exact match
This commit is contained in:
committed by
Jonas Schnelli
parent
ae479bc45b
commit
18476423fb
@@ -54,6 +54,11 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||||||
self.nodes[0].generate(121)
|
self.nodes[0].generate(121)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
|
||||||
|
# ensure that setting changePosition in fundraw with an exact match is handled properly
|
||||||
|
rawmatch = self.nodes[2].createrawtransaction([], {self.nodes[2].getnewaddress():50})
|
||||||
|
rawmatch = self.nodes[2].fundrawtransaction(rawmatch, {"changePosition":1, "subtractFeeFromOutputs":[0]})
|
||||||
|
assert_equal(rawmatch["changepos"], -1)
|
||||||
|
|
||||||
watchonly_address = self.nodes[0].getnewaddress()
|
watchonly_address = self.nodes[0].getnewaddress()
|
||||||
watchonly_pubkey = self.nodes[0].validateaddress(watchonly_address)["pubkey"]
|
watchonly_pubkey = self.nodes[0].validateaddress(watchonly_address)["pubkey"]
|
||||||
watchonly_amount = Decimal(200)
|
watchonly_amount = Decimal(200)
|
||||||
|
|||||||
@@ -2587,9 +2587,10 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
|
|||||||
vector<CTxOut>::iterator position = txNew.vout.begin()+nChangePosInOut;
|
vector<CTxOut>::iterator position = txNew.vout.begin()+nChangePosInOut;
|
||||||
txNew.vout.insert(position, newTxOut);
|
txNew.vout.insert(position, newTxOut);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
reservekey.ReturnKey();
|
reservekey.ReturnKey();
|
||||||
|
nChangePosInOut = -1;
|
||||||
|
}
|
||||||
|
|
||||||
// Fill vin
|
// Fill vin
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user