mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-27 17:31:40 +02:00
wallet: do not count wallet utxos as external
This commit is contained in:
parent
f7a1e676d5
commit
c3981e379f
@ -699,19 +699,6 @@ void FundTransaction(CWallet& wallet, CMutableTransaction& tx, CAmount& fee_out,
|
|||||||
setSubtractFeeFromOutputs.insert(pos);
|
setSubtractFeeFromOutputs.insert(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch specified UTXOs from the UTXO set to get the scriptPubKeys and values of the outputs being selected
|
|
||||||
// and to match with the given solving_data. Only used for non-wallet outputs.
|
|
||||||
std::map<COutPoint, Coin> coins;
|
|
||||||
for (const CTxIn& txin : tx.vin) {
|
|
||||||
coins[txin.prevout]; // Create empty map entry keyed by prevout.
|
|
||||||
}
|
|
||||||
wallet.chain().findCoins(coins);
|
|
||||||
for (const auto& coin : coins) {
|
|
||||||
if (!coin.second.out.IsNull()) {
|
|
||||||
coinControl.SelectExternal(coin.first, coin.second.out);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bilingual_str error;
|
bilingual_str error;
|
||||||
|
|
||||||
if (!FundTransaction(wallet, tx, fee_out, change_position, error, lockUnspents, setSubtractFeeFromOutputs, coinControl)) {
|
if (!FundTransaction(wallet, tx, fee_out, change_position, error, lockUnspents, setSubtractFeeFromOutputs, coinControl)) {
|
||||||
|
@ -1018,14 +1018,28 @@ bool FundTransaction(CWallet& wallet, CMutableTransaction& tx, CAmount& nFeeRet,
|
|||||||
|
|
||||||
coinControl.fAllowOtherInputs = true;
|
coinControl.fAllowOtherInputs = true;
|
||||||
|
|
||||||
for (const CTxIn& txin : tx.vin) {
|
|
||||||
coinControl.Select(txin.prevout);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Acquire the locks to prevent races to the new locked unspents between the
|
// Acquire the locks to prevent races to the new locked unspents between the
|
||||||
// CreateTransaction call and LockCoin calls (when lockUnspents is true).
|
// CreateTransaction call and LockCoin calls (when lockUnspents is true).
|
||||||
LOCK(wallet.cs_wallet);
|
LOCK(wallet.cs_wallet);
|
||||||
|
|
||||||
|
// Fetch specified UTXOs from the UTXO set to get the scriptPubKeys and values of the outputs being selected
|
||||||
|
// and to match with the given solving_data. Only used for non-wallet outputs.
|
||||||
|
std::map<COutPoint, Coin> coins;
|
||||||
|
for (const CTxIn& txin : tx.vin) {
|
||||||
|
coins[txin.prevout]; // Create empty map entry keyed by prevout.
|
||||||
|
}
|
||||||
|
wallet.chain().findCoins(coins);
|
||||||
|
|
||||||
|
for (const CTxIn& txin : tx.vin) {
|
||||||
|
// if it's not in the wallet and corresponding UTXO is found than select as external output
|
||||||
|
const auto& outPoint = txin.prevout;
|
||||||
|
if (wallet.mapWallet.find(outPoint.hash) == wallet.mapWallet.end() && !coins[outPoint].out.IsNull()) {
|
||||||
|
coinControl.SelectExternal(outPoint, coins[outPoint].out);
|
||||||
|
} else {
|
||||||
|
coinControl.Select(outPoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FeeCalculation fee_calc_out;
|
FeeCalculation fee_calc_out;
|
||||||
std::optional<CreatedTransactionResult> txr = CreateTransaction(wallet, vecSend, nChangePosInOut, error, coinControl, fee_calc_out, false);
|
std::optional<CreatedTransactionResult> txr = CreateTransaction(wallet, vecSend, nChangePosInOut, error, coinControl, fee_calc_out, false);
|
||||||
if (!txr) return false;
|
if (!txr) return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user