Skip to content

Commit 9c2a8b8

Browse files
committed
Do not treat bare multisig as IsMine
Such outputs can still be watched, and signed for, but they aren't treated as valid payments. That means they won't cause transactions to appear in listtransactions, their outputs to be shown under listunspent, or affect balances.
1 parent 08f3228 commit 9c2a8b8

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

src/script/ismine.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ static isminetype IsMineInner(const CKeyStore& keystore, const CScript& scriptPu
123123

124124
case TX_MULTISIG:
125125
{
126+
// Never treat bare multisig outputs as ours (they can still be made watchonly-though)
127+
if (sigversion == IsMineSigVersion::TOP) break;
128+
126129
// Only consider transactions "mine" if we own ALL the
127130
// keys involved. Multi-signature transactions that are
128131
// partially owned (somebody else has a key that can spend

src/test/script_standard_tests.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,14 @@ BOOST_AUTO_TEST_CASE(script_standard_IsMine)
561561
keystore.AddKey(keys[1]);
562562

563563
result = IsMine(keystore, scriptPubKey, isInvalid);
564-
BOOST_CHECK_EQUAL(result, ISMINE_SPENDABLE);
564+
BOOST_CHECK_EQUAL(result, ISMINE_NO);
565+
BOOST_CHECK(!isInvalid);
566+
567+
// Keystore has 2/2 keys and the script
568+
keystore.AddCScript(scriptPubKey);
569+
570+
result = IsMine(keystore, scriptPubKey, isInvalid);
571+
BOOST_CHECK_EQUAL(result, ISMINE_NO);
565572
BOOST_CHECK(!isInvalid);
566573
}
567574

test/functional/feature_segwit.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,10 @@ def run_test(self):
311311
v = self.nodes[0].getaddressinfo(i)
312312
if (v['isscript']):
313313
[bare, p2sh, p2wsh, p2sh_p2wsh] = self.p2sh_address_to_script(v)
314-
# bare and p2sh multisig with compressed keys should always be spendable
315-
spendable_anytime.extend([bare, p2sh])
314+
# p2sh multisig with compressed keys should always be spendable
315+
spendable_anytime.extend([p2sh])
316+
# bare multisig can be watched and signed, but is not treated as ours
317+
solvable_after_importaddress.extend([bare])
316318
# P2WSH and P2SH(P2WSH) multisig with compressed keys are spendable after direct importaddress
317319
spendable_after_importaddress.extend([p2wsh, p2sh_p2wsh])
318320
else:
@@ -328,8 +330,10 @@ def run_test(self):
328330
v = self.nodes[0].getaddressinfo(i)
329331
if (v['isscript']):
330332
[bare, p2sh, p2wsh, p2sh_p2wsh] = self.p2sh_address_to_script(v)
331-
# bare and p2sh multisig with uncompressed keys should always be spendable
332-
spendable_anytime.extend([bare, p2sh])
333+
# p2sh multisig with uncompressed keys should always be spendable
334+
spendable_anytime.extend([p2sh])
335+
# bare multisig can be watched and signed, but is not treated as ours
336+
solvable_after_importaddress.extend([bare])
333337
# P2WSH and P2SH(P2WSH) multisig with uncompressed keys are never seen
334338
unseen_anytime.extend([p2wsh, p2sh_p2wsh])
335339
else:

0 commit comments

Comments
 (0)