[wallet] ListCoins: include watch-only for wallets without private keys
This makes them available in GUI coin selection.
This commit is contained in:
parent
8021392b82
commit
40537f0909
1 changed files with 6 additions and 2 deletions
|
@ -2160,7 +2160,7 @@ std::map<CTxDestination, std::vector<COutput>> CWallet::ListCoins(interfaces::Ch
|
||||||
|
|
||||||
for (const COutput& coin : availableCoins) {
|
for (const COutput& coin : availableCoins) {
|
||||||
CTxDestination address;
|
CTxDestination address;
|
||||||
if (coin.fSpendable &&
|
if ((coin.fSpendable || (IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS) && coin.fSolvable)) &&
|
||||||
ExtractDestination(FindNonChangeParentOutput(*coin.tx->tx, coin.i).scriptPubKey, address)) {
|
ExtractDestination(FindNonChangeParentOutput(*coin.tx->tx, coin.i).scriptPubKey, address)) {
|
||||||
result[address].emplace_back(std::move(coin));
|
result[address].emplace_back(std::move(coin));
|
||||||
}
|
}
|
||||||
|
@ -2168,12 +2168,16 @@ std::map<CTxDestination, std::vector<COutput>> CWallet::ListCoins(interfaces::Ch
|
||||||
|
|
||||||
std::vector<COutPoint> lockedCoins;
|
std::vector<COutPoint> lockedCoins;
|
||||||
ListLockedCoins(lockedCoins);
|
ListLockedCoins(lockedCoins);
|
||||||
|
// Include watch-only for wallets without private keys
|
||||||
|
const bool include_watch_only = IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS);
|
||||||
|
const isminetype is_mine_filter = include_watch_only ? ISMINE_WATCH_ONLY : ISMINE_SPENDABLE;
|
||||||
for (const COutPoint& output : lockedCoins) {
|
for (const COutPoint& output : lockedCoins) {
|
||||||
auto it = mapWallet.find(output.hash);
|
auto it = mapWallet.find(output.hash);
|
||||||
if (it != mapWallet.end()) {
|
if (it != mapWallet.end()) {
|
||||||
int depth = it->second.GetDepthInMainChain();
|
int depth = it->second.GetDepthInMainChain();
|
||||||
if (depth >= 0 && output.n < it->second.tx->vout.size() &&
|
if (depth >= 0 && output.n < it->second.tx->vout.size() &&
|
||||||
IsMine(it->second.tx->vout[output.n]) == ISMINE_SPENDABLE) {
|
IsMine(it->second.tx->vout[output.n]) == is_mine_filter
|
||||||
|
) {
|
||||||
CTxDestination address;
|
CTxDestination address;
|
||||||
if (ExtractDestination(FindNonChangeParentOutput(*it->second.tx, output.n).scriptPubKey, address)) {
|
if (ExtractDestination(FindNonChangeParentOutput(*it->second.tx, output.n).scriptPubKey, address)) {
|
||||||
result[address].emplace_back(
|
result[address].emplace_back(
|
||||||
|
|
Loading…
Reference in a new issue