Skip to content

Commit 46880ed

Browse files
committed
Merge #7688: List solvability in listunspent output and improve help
c3932b3 List solvability in listunspent output and improve help (Pieter Wuille)
2 parents c4e8390 + c3932b3 commit 46880ed

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

src/qt/walletmodel.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ void WalletModel::getOutputs(const std::vector<COutPoint>& vOutpoints, std::vect
572572
if (!wallet->mapWallet.count(outpoint.hash)) continue;
573573
int nDepth = wallet->mapWallet[outpoint.hash].GetDepthInMainChain();
574574
if (nDepth < 0) continue;
575-
COutput out(&wallet->mapWallet[outpoint.hash], outpoint.n, nDepth, true);
575+
COutput out(&wallet->mapWallet[outpoint.hash], outpoint.n, nDepth, true, true);
576576
vOutputs.push_back(out);
577577
}
578578
}
@@ -599,7 +599,7 @@ void WalletModel::listCoins(std::map<QString, std::vector<COutput> >& mapCoins)
599599
if (!wallet->mapWallet.count(outpoint.hash)) continue;
600600
int nDepth = wallet->mapWallet[outpoint.hash].GetDepthInMainChain();
601601
if (nDepth < 0) continue;
602-
COutput out(&wallet->mapWallet[outpoint.hash], outpoint.n, nDepth, true);
602+
COutput out(&wallet->mapWallet[outpoint.hash], outpoint.n, nDepth, true, true);
603603
if (outpoint.n < out.tx->vout.size() && wallet->IsMine(out.tx->vout[outpoint.n]) == ISMINE_SPENDABLE)
604604
vCoins.push_back(out);
605605
}
@@ -611,7 +611,7 @@ void WalletModel::listCoins(std::map<QString, std::vector<COutput> >& mapCoins)
611611
while (wallet->IsChange(cout.tx->vout[cout.i]) && cout.tx->vin.size() > 0 && wallet->IsMine(cout.tx->vin[0]))
612612
{
613613
if (!wallet->mapWallet.count(cout.tx->vin[0].prevout.hash)) break;
614-
cout = COutput(&wallet->mapWallet[cout.tx->vin[0].prevout.hash], cout.tx->vin[0].prevout.n, 0, true);
614+
cout = COutput(&wallet->mapWallet[cout.tx->vin[0].prevout.hash], cout.tx->vin[0].prevout.n, 0, true, true);
615615
}
616616

617617
CTxDestination address;

src/wallet/rpcwallet.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2347,7 +2347,9 @@ UniValue listunspent(const UniValue& params, bool fHelp)
23472347
" \"account\" : \"account\", (string) DEPRECATED. The associated account, or \"\" for the default account\n"
23482348
" \"scriptPubKey\" : \"key\", (string) the script key\n"
23492349
" \"amount\" : x.xxx, (numeric) the transaction amount in " + CURRENCY_UNIT + "\n"
2350-
" \"confirmations\" : n (numeric) The number of confirmations\n"
2350+
" \"confirmations\" : n, (numeric) The number of confirmations\n"
2351+
" \"spendable\" : xxx, (bool) Whether we have the private keys to spend this output\n"
2352+
" \"solvable\" : xxx (bool) Whether we know how to spend this output, ignoring the lack of keys\n"
23512353
" }\n"
23522354
" ,...\n"
23532355
"]\n"
@@ -2424,6 +2426,7 @@ UniValue listunspent(const UniValue& params, bool fHelp)
24242426
entry.push_back(Pair("amount",ValueFromAmount(nValue)));
24252427
entry.push_back(Pair("confirmations",out.nDepth));
24262428
entry.push_back(Pair("spendable", out.fSpendable));
2429+
entry.push_back(Pair("solvable", out.fSolvable));
24272430
results.push_back(entry);
24282431
}
24292432

@@ -2445,6 +2448,7 @@ UniValue fundrawtransaction(const UniValue& params, bool fHelp)
24452448
"Note that all existing inputs must have their previous output transaction be in the wallet.\n"
24462449
"Note that all inputs selected must be of standard form and P2SH scripts must be\n"
24472450
"in the wallet using importaddress or addmultisigaddress (to calculate fees).\n"
2451+
"You can see whether this is the case by checking the \"solvable\" field in the listunspent output.\n"
24482452
"Only pay-to-pubkey, multisig, and P2SH versions thereof are currently supported for watch-only\n"
24492453
"\nArguments:\n"
24502454
"1. \"hexstring\" (string, required) The hex string of the raw transaction\n"

src/wallet/test/wallet_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static void add_coin(const CAmount& nValue, int nAge = 6*24, bool fIsFromMe = fa
4848
wtx->fDebitCached = true;
4949
wtx->nDebitCached = 1;
5050
}
51-
COutput output(wtx, nInput, nAge, true);
51+
COutput output(wtx, nInput, nAge, true, true);
5252
vCoins.push_back(output);
5353
}
5454

src/wallet/wallet.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1691,7 +1691,8 @@ void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const
16911691
(!coinControl || !coinControl->HasSelected() || coinControl->fAllowOtherInputs || coinControl->IsSelected(COutPoint((*it).first, i))))
16921692
vCoins.push_back(COutput(pcoin, i, nDepth,
16931693
((mine & ISMINE_SPENDABLE) != ISMINE_NO) ||
1694-
(coinControl && coinControl->fAllowWatchOnly && (mine & ISMINE_WATCH_SOLVABLE) != ISMINE_NO)));
1694+
(coinControl && coinControl->fAllowWatchOnly && (mine & ISMINE_WATCH_SOLVABLE) != ISMINE_NO),
1695+
(mine & (ISMINE_SPENDABLE | ISMINE_WATCH_SOLVABLE)) != ISMINE_NO));
16951696
}
16961697
}
16971698
}

src/wallet/wallet.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,10 +414,11 @@ class COutput
414414
int i;
415415
int nDepth;
416416
bool fSpendable;
417+
bool fSolvable;
417418

418-
COutput(const CWalletTx *txIn, int iIn, int nDepthIn, bool fSpendableIn)
419+
COutput(const CWalletTx *txIn, int iIn, int nDepthIn, bool fSpendableIn, bool fSolvableIn)
419420
{
420-
tx = txIn; i = iIn; nDepth = nDepthIn; fSpendable = fSpendableIn;
421+
tx = txIn; i = iIn; nDepth = nDepthIn; fSpendable = fSpendableIn; fSolvable = fSolvableIn;
421422
}
422423

423424
std::string ToString() const;

0 commit comments

Comments
 (0)