Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1502// Set the user desired locktime1503coinControl.m_locktime = tx.nLockTime;1505// Set the user desired version1506coinControl.m_version = tx.version;1508// Acquire the locks to prevent races to the new locked unspents between the1509// CreateTransaction call and LockCoin calls (when lockUnspents is true).1510LOCK(wallet.cs_wallet);1512// Fetch specified UTXOs from the UTXO set to get the scriptPubKeys and values of the outputs being selected1513// and to match with the given solving_data. Only used for non-wallet outputs.1514std::map<COutPoint, Coin> coins;1515for (const CTxIn& txin : tx.vin) {1516coins[txin.prevout]; // Create empty map entry keyed by prevout.1517}1518wallet.chain().findCoins(coins);1520for (const CTxIn& txin : tx.vin) {1521const auto& outPoint = txin.prevout;1522PreselectedInput& preset_txin = coinControl.Select(outPoint);1523if (!wallet.IsMine(outPoint)) {1524if (coins[outPoint].out.IsNull()) {1525return util::Error{_("Unable to find UTXO for external input")};1526}1528// The input was not in the wallet, but is in the UTXO set, so select as external1529preset_txin.SetTxOut(coins[outPoint].out);1530}1531preset_txin.SetSequence(txin.nSequence);1532preset_txin.SetScriptSig(txin.scriptSig);1533preset_txin.SetScriptWitness(txin.scriptWitness);1534}1536auto res = CreateTransaction(wallet, vecSend, change_pos, coinControl, false);1537if (!res) {1538return res;1539}1541if (lockUnspents) {1542for (const CTxIn& txin : res->tx->vin) {1543wallet.LockCoin(txin.prevout, /*persist=*/false);1544}1545}1547return res;1548}1549} // namespace wallet