Skip to content

Commit 4356878

Browse files
committed
External input fund support cleanups
Synchronize error checking for external inputs Rename external output Select to SelectExternal Const FundTransaction variables
1 parent c79d9fb commit 4356878

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/wallet/coincontrol.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class CCoinControl
9393
setSelected.insert(output);
9494
}
9595

96-
void Select(const COutPoint& outpoint, const CTxOut& txout)
96+
void SelectExternal(const COutPoint& outpoint, const CTxOut& txout)
9797
{
9898
setSelected.insert(outpoint);
9999
m_external_txouts.emplace(outpoint, txout);

src/wallet/rpcwallet.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3292,15 +3292,15 @@ void FundTransaction(CWallet& wallet, CMutableTransaction& tx, CAmount& fee_out,
32923292
}
32933293

32943294
if (options.exists("solving_data")) {
3295-
UniValue solving_data = options["solving_data"].get_obj();
3295+
const UniValue solving_data = options["solving_data"].get_obj();
32963296
if (solving_data.exists("pubkeys")) {
32973297
for (const UniValue& pk_univ : solving_data["pubkeys"].get_array().getValues()) {
32983298
const std::string& pk_str = pk_univ.get_str();
32993299
if (!IsHex(pk_str)) {
33003300
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("'%s' is not hex", pk_str));
33013301
}
33023302
const std::vector<unsigned char> data(ParseHex(pk_str));
3303-
CPubKey pubkey(data.begin(), data.end());
3303+
const CPubKey pubkey(data.begin(), data.end());
33043304
if (!pubkey.IsFullyValid()) {
33053305
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("'%s' is not a valid public key", pk_str));
33063306
}
@@ -3365,7 +3365,7 @@ void FundTransaction(CWallet& wallet, CMutableTransaction& tx, CAmount& fee_out,
33653365
wallet.chain().findCoins(coins);
33663366
for (const auto& coin : coins) {
33673367
if (!coin.second.out.IsNull()) {
3368-
coinControl.Select(coin.first, coin.second.out);
3368+
coinControl.SelectExternal(coin.first, coin.second.out);
33693369
}
33703370
}
33713371

src/wallet/spend.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ bool SelectCoins(const CWallet& wallet, const std::vector<COutput>& vAvailableCo
475475

476476
CInputCoin coin(outpoint, txout, input_bytes);
477477
nValueFromPresetInputs += coin.txout.nValue;
478-
if (coin.m_input_bytes <= 0) {
478+
if (coin.m_input_bytes == -1) {
479479
return false; // Not solvable, can't estimate size for fee
480480
}
481481
coin.effective_value = coin.txout.nValue - coin_selection_params.m_effective_feerate.GetFee(coin.m_input_bytes);
@@ -814,7 +814,7 @@ static bool CreateTransactionInternal(
814814
// Calculate the transaction fee
815815
TxSize tx_sizes = CalculateMaximumSignedTxSize(CTransaction(txNew), &wallet, &coin_control);
816816
int nBytes = tx_sizes.vsize;
817-
if (nBytes < 0) {
817+
if (nBytes == -1) {
818818
error = _("Missing solving data for estimating transaction size");
819819
return false;
820820
}

0 commit comments

Comments
 (0)