Skip to content

Commit d3354c5

Browse files
committed
Add have-pubkey distinction to ISMINE flags
This indicates that, eg, we have a public key for a key which may be used as a pay-to-pubkey-hash. It generally means that we can create a valid scriptSig except for missing private key(s) with which to create signatures.
1 parent 5c17059 commit d3354c5

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

src/qt/transactiondesc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
165165

166166
if (fAllFromMe)
167167
{
168-
if(fAllFromMe == ISMINE_WATCH_ONLY)
168+
if(fAllFromMe & ISMINE_WATCH_ONLY)
169169
strHTML += "<b>" + tr("From") + ":</b> " + tr("watch-only") + "<br>";
170170

171171
//
@@ -190,7 +190,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
190190
strHTML += GUIUtil::HtmlEscape(CBitcoinAddress(address).ToString());
191191
if(toSelf == ISMINE_SPENDABLE)
192192
strHTML += " (own address)";
193-
else if(toSelf == ISMINE_WATCH_ONLY)
193+
else if(toSelf & ISMINE_WATCH_ONLY)
194194
strHTML += " (watch-only)";
195195
strHTML += "<br>";
196196
}

src/qt/transactionrecord.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
5656
CTxDestination address;
5757
sub.idx = parts.size(); // sequence number
5858
sub.credit = txout.nValue;
59-
sub.involvesWatchAddress = mine == ISMINE_WATCH_ONLY;
59+
sub.involvesWatchAddress = mine & ISMINE_WATCH_ONLY;
6060
if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*wallet, address))
6161
{
6262
// Received by Bitcoin Address
@@ -86,15 +86,15 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
8686
BOOST_FOREACH(const CTxIn& txin, wtx.vin)
8787
{
8888
isminetype mine = wallet->IsMine(txin);
89-
if(mine == ISMINE_WATCH_ONLY) involvesWatchAddress = true;
89+
if(mine & ISMINE_WATCH_ONLY) involvesWatchAddress = true;
9090
if(fAllFromMe > mine) fAllFromMe = mine;
9191
}
9292

9393
isminetype fAllToMe = ISMINE_SPENDABLE;
9494
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
9595
{
9696
isminetype mine = wallet->IsMine(txout);
97-
if(mine == ISMINE_WATCH_ONLY) involvesWatchAddress = true;
97+
if(mine & ISMINE_WATCH_ONLY) involvesWatchAddress = true;
9898
if(fAllToMe > mine) fAllToMe = mine;
9999
}
100100

src/wallet/wallet_ismine.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "keystore.h"
1010
#include "script/script.h"
1111
#include "script/standard.h"
12+
#include "script/sign.h"
1213

1314
#include <boost/foreach.hpp>
1415

@@ -40,7 +41,7 @@ isminetype IsMine(const CKeyStore &keystore, const CScript& scriptPubKey)
4041
txnouttype whichType;
4142
if (!Solver(scriptPubKey, whichType, vSolutions)) {
4243
if (keystore.HaveWatchOnly(scriptPubKey))
43-
return ISMINE_WATCH_ONLY;
44+
return ISMINE_WATCH_NOPUBKEY;
4445
return ISMINE_NO;
4546
}
4647

@@ -85,7 +86,10 @@ isminetype IsMine(const CKeyStore &keystore, const CScript& scriptPubKey)
8586
}
8687
}
8788

88-
if (keystore.HaveWatchOnly(scriptPubKey))
89-
return ISMINE_WATCH_ONLY;
89+
if (keystore.HaveWatchOnly(scriptPubKey)) {
90+
// TODO: This could be optimized some by doing some work after the above solver
91+
CScript scriptSig;
92+
return ProduceSignature(DummySignatureCreator(&keystore), scriptPubKey, scriptSig) ? ISMINE_WATCH_PUBKEY : ISMINE_WATCH_NOPUBKEY;
93+
}
9094
return ISMINE_NO;
9195
}

src/wallet/wallet_ismine.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ class CScript;
1616
enum isminetype
1717
{
1818
ISMINE_NO = 0,
19-
ISMINE_WATCH_ONLY = 1,
20-
ISMINE_SPENDABLE = 2,
19+
//! Indicates that we dont know how to create a scriptSig that would solve this if we were given the appropriate private keys
20+
ISMINE_WATCH_NOPUBKEY = 1,
21+
//! Indicates that we know how to create a scriptSig that would solve this if we were given the appropriate private keys
22+
ISMINE_WATCH_PUBKEY = 2,
23+
ISMINE_WATCH_ONLY = ISMINE_WATCH_NOPUBKEY | ISMINE_WATCH_PUBKEY,
24+
ISMINE_SPENDABLE = 4,
2125
ISMINE_ALL = ISMINE_WATCH_ONLY | ISMINE_SPENDABLE
2226
};
2327
/** used for bitflags of isminetype */

0 commit comments

Comments
 (0)