Skip to content

Commit c3932b3

Browse files
committed
List solvability in listunspent output and improve help
1 parent 48f3905 commit c3932b3

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
@@ -2348,7 +2348,9 @@ UniValue listunspent(const UniValue& params, bool fHelp)
23482348
" \"account\" : \"account\", (string) DEPRECATED. The associated account, or \"\" for the default account\n"
23492349
" \"scriptPubKey\" : \"key\", (string) the script key\n"
23502350
" \"amount\" : x.xxx, (numeric) the transaction amount in " + CURRENCY_UNIT + "\n"
2351-
" \"confirmations\" : n (numeric) The number of confirmations\n"
2351+
" \"confirmations\" : n, (numeric) The number of confirmations\n"
2352+
" \"spendable\" : xxx, (bool) Whether we have the private keys to spend this output\n"
2353+
" \"solvable\" : xxx (bool) Whether we know how to spend this output, ignoring the lack of keys\n"
23522354
" }\n"
23532355
" ,...\n"
23542356
"]\n"
@@ -2425,6 +2427,7 @@ UniValue listunspent(const UniValue& params, bool fHelp)
24252427
entry.push_back(Pair("amount",ValueFromAmount(nValue)));
24262428
entry.push_back(Pair("confirmations",out.nDepth));
24272429
entry.push_back(Pair("spendable", out.fSpendable));
2430+
entry.push_back(Pair("solvable", out.fSolvable));
24282431
results.push_back(entry);
24292432
}
24302433

@@ -2446,6 +2449,7 @@ UniValue fundrawtransaction(const UniValue& params, bool fHelp)
24462449
"Note that all existing inputs must have their previous output transaction be in the wallet.\n"
24472450
"Note that all inputs selected must be of standard form and P2SH scripts must be"
24482451
"in the wallet using importaddress or addmultisigaddress (to calculate fees).\n"
2452+
"You can see whether this is the case by checking the \"solvable\" field in the listunspent output.\n"
24492453
"Only pay-to-pubkey, multisig, and P2SH versions thereof are currently supported for watch-only\n"
24502454
"\nArguments:\n"
24512455
"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
@@ -1675,7 +1675,8 @@ void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const
16751675
(!coinControl || !coinControl->HasSelected() || coinControl->fAllowOtherInputs || coinControl->IsSelected((*it).first, i)))
16761676
vCoins.push_back(COutput(pcoin, i, nDepth,
16771677
((mine & ISMINE_SPENDABLE) != ISMINE_NO) ||
1678-
(coinControl && coinControl->fAllowWatchOnly && (mine & ISMINE_WATCH_SOLVABLE) != ISMINE_NO)));
1678+
(coinControl && coinControl->fAllowWatchOnly && (mine & ISMINE_WATCH_SOLVABLE) != ISMINE_NO),
1679+
(mine & (ISMINE_SPENDABLE | ISMINE_WATCH_SOLVABLE)) != ISMINE_NO));
16791680
}
16801681
}
16811682
}

src/wallet/wallet.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,10 +412,11 @@ class COutput
412412
int i;
413413
int nDepth;
414414
bool fSpendable;
415+
bool fSolvable;
415416

416-
COutput(const CWalletTx *txIn, int iIn, int nDepthIn, bool fSpendableIn)
417+
COutput(const CWalletTx *txIn, int iIn, int nDepthIn, bool fSpendableIn, bool fSolvableIn)
417418
{
418-
tx = txIn; i = iIn; nDepth = nDepthIn; fSpendable = fSpendableIn;
419+
tx = txIn; i = iIn; nDepth = nDepthIn; fSpendable = fSpendableIn; fSolvable = fSolvableIn;
419420
}
420421

421422
std::string ToString() const;

0 commit comments

Comments
 (0)