Line data Source code
1 : // Copyright (c) 2017-2019 The Bitcoin Core developers
2 : // Distributed under the MIT software license, see the accompanying
3 : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 :
5 : #include <key.h>
6 : #include <node/context.h>
7 : #include <script/script.h>
8 : #include <script/standard.h>
9 : #include <test/util/setup_common.h>
10 : #include <wallet/ismine.h>
11 : #include <wallet/wallet.h>
12 :
13 : #include <boost/test/unit_test.hpp>
14 :
15 :
16 89 : BOOST_FIXTURE_TEST_SUITE(ismine_tests, BasicTestingSetup)
17 :
18 95 : BOOST_AUTO_TEST_CASE(ismine_standard)
19 : {
20 2 : CKey keys[2];
21 2 : CPubKey pubkeys[2];
22 3 : for (int i = 0; i < 2; i++) {
23 2 : keys[i].MakeNewKey(true);
24 2 : pubkeys[i] = keys[i].GetPubKey();
25 : }
26 :
27 1 : CKey uncompressedKey;
28 1 : uncompressedKey.MakeNewKey(false);
29 1 : CPubKey uncompressedPubkey = uncompressedKey.GetPubKey();
30 1 : NodeContext node;
31 1 : std::unique_ptr<interfaces::Chain> chain = interfaces::MakeChain(node);
32 :
33 1 : CScript scriptPubKey;
34 1 : isminetype result;
35 :
36 : // P2PK compressed
37 : {
38 1 : CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
39 1 : keystore.SetupLegacyScriptPubKeyMan();
40 1 : LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
41 1 : scriptPubKey = GetScriptForRawPubKey(pubkeys[0]);
42 :
43 : // Keystore does not have key
44 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
45 1 : BOOST_CHECK_EQUAL(result, ISMINE_NO);
46 :
47 : // Keystore has key
48 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
49 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
50 1 : BOOST_CHECK_EQUAL(result, ISMINE_SPENDABLE);
51 1 : }
52 :
53 : // P2PK uncompressed
54 : {
55 1 : CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
56 1 : keystore.SetupLegacyScriptPubKeyMan();
57 1 : LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
58 1 : scriptPubKey = GetScriptForRawPubKey(uncompressedPubkey);
59 :
60 : // Keystore does not have key
61 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
62 1 : BOOST_CHECK_EQUAL(result, ISMINE_NO);
63 :
64 : // Keystore has key
65 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(uncompressedKey));
66 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
67 1 : BOOST_CHECK_EQUAL(result, ISMINE_SPENDABLE);
68 1 : }
69 :
70 : // P2PKH compressed
71 : {
72 1 : CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
73 1 : keystore.SetupLegacyScriptPubKeyMan();
74 1 : LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
75 1 : scriptPubKey = GetScriptForDestination(PKHash(pubkeys[0]));
76 :
77 : // Keystore does not have key
78 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
79 1 : BOOST_CHECK_EQUAL(result, ISMINE_NO);
80 :
81 : // Keystore has key
82 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
83 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
84 1 : BOOST_CHECK_EQUAL(result, ISMINE_SPENDABLE);
85 1 : }
86 :
87 : // P2PKH uncompressed
88 : {
89 1 : CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
90 1 : keystore.SetupLegacyScriptPubKeyMan();
91 1 : LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
92 1 : scriptPubKey = GetScriptForDestination(PKHash(uncompressedPubkey));
93 :
94 : // Keystore does not have key
95 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
96 1 : BOOST_CHECK_EQUAL(result, ISMINE_NO);
97 :
98 : // Keystore has key
99 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(uncompressedKey));
100 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
101 1 : BOOST_CHECK_EQUAL(result, ISMINE_SPENDABLE);
102 1 : }
103 :
104 : // P2SH
105 : {
106 1 : CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
107 1 : keystore.SetupLegacyScriptPubKeyMan();
108 1 : LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
109 :
110 1 : CScript redeemScript = GetScriptForDestination(PKHash(pubkeys[0]));
111 1 : scriptPubKey = GetScriptForDestination(ScriptHash(redeemScript));
112 :
113 : // Keystore does not have redeemScript or key
114 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
115 1 : BOOST_CHECK_EQUAL(result, ISMINE_NO);
116 :
117 : // Keystore has redeemScript but no key
118 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(redeemScript));
119 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
120 1 : BOOST_CHECK_EQUAL(result, ISMINE_NO);
121 :
122 : // Keystore has redeemScript and key
123 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
124 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
125 1 : BOOST_CHECK_EQUAL(result, ISMINE_SPENDABLE);
126 1 : }
127 :
128 : // (P2PKH inside) P2SH inside P2SH (invalid)
129 : {
130 1 : CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
131 1 : keystore.SetupLegacyScriptPubKeyMan();
132 1 : LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
133 :
134 1 : CScript redeemscript_inner = GetScriptForDestination(PKHash(pubkeys[0]));
135 1 : CScript redeemscript = GetScriptForDestination(ScriptHash(redeemscript_inner));
136 1 : scriptPubKey = GetScriptForDestination(ScriptHash(redeemscript));
137 :
138 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(redeemscript));
139 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(redeemscript_inner));
140 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(scriptPubKey));
141 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
142 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
143 1 : BOOST_CHECK_EQUAL(result, ISMINE_NO);
144 1 : }
145 :
146 : // (P2PKH inside) P2SH inside P2WSH (invalid)
147 : {
148 1 : CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
149 1 : keystore.SetupLegacyScriptPubKeyMan();
150 1 : LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
151 :
152 1 : CScript redeemscript = GetScriptForDestination(PKHash(pubkeys[0]));
153 1 : CScript witnessscript = GetScriptForDestination(ScriptHash(redeemscript));
154 1 : scriptPubKey = GetScriptForDestination(WitnessV0ScriptHash(witnessscript));
155 :
156 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(witnessscript));
157 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(redeemscript));
158 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(scriptPubKey));
159 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
160 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
161 1 : BOOST_CHECK_EQUAL(result, ISMINE_NO);
162 1 : }
163 :
164 : // P2WPKH inside P2WSH (invalid)
165 : {
166 1 : CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
167 1 : keystore.SetupLegacyScriptPubKeyMan();
168 1 : LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
169 :
170 1 : CScript witnessscript = GetScriptForDestination(WitnessV0KeyHash(pubkeys[0]));
171 1 : scriptPubKey = GetScriptForDestination(WitnessV0ScriptHash(witnessscript));
172 :
173 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(witnessscript));
174 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(scriptPubKey));
175 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
176 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
177 1 : BOOST_CHECK_EQUAL(result, ISMINE_NO);
178 1 : }
179 :
180 : // (P2PKH inside) P2WSH inside P2WSH (invalid)
181 : {
182 1 : CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
183 1 : keystore.SetupLegacyScriptPubKeyMan();
184 1 : LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
185 :
186 1 : CScript witnessscript_inner = GetScriptForDestination(PKHash(pubkeys[0]));
187 1 : CScript witnessscript = GetScriptForDestination(WitnessV0ScriptHash(witnessscript_inner));
188 1 : scriptPubKey = GetScriptForDestination(WitnessV0ScriptHash(witnessscript));
189 :
190 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(witnessscript_inner));
191 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(witnessscript));
192 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(scriptPubKey));
193 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
194 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
195 1 : BOOST_CHECK_EQUAL(result, ISMINE_NO);
196 1 : }
197 :
198 : // P2WPKH compressed
199 : {
200 1 : CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
201 1 : keystore.SetupLegacyScriptPubKeyMan();
202 1 : LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
203 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
204 :
205 1 : scriptPubKey = GetScriptForDestination(WitnessV0KeyHash(pubkeys[0]));
206 :
207 : // Keystore implicitly has key and P2SH redeemScript
208 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(scriptPubKey));
209 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
210 1 : BOOST_CHECK_EQUAL(result, ISMINE_SPENDABLE);
211 1 : }
212 :
213 : // P2WPKH uncompressed
214 : {
215 1 : CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
216 1 : keystore.SetupLegacyScriptPubKeyMan();
217 1 : LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
218 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(uncompressedKey));
219 :
220 1 : scriptPubKey = GetScriptForDestination(WitnessV0KeyHash(uncompressedPubkey));
221 :
222 : // Keystore has key, but no P2SH redeemScript
223 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
224 1 : BOOST_CHECK_EQUAL(result, ISMINE_NO);
225 :
226 : // Keystore has key and P2SH redeemScript
227 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(scriptPubKey));
228 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
229 1 : BOOST_CHECK_EQUAL(result, ISMINE_NO);
230 1 : }
231 :
232 : // scriptPubKey multisig
233 : {
234 1 : CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
235 1 : keystore.SetupLegacyScriptPubKeyMan();
236 1 : LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
237 :
238 1 : scriptPubKey = GetScriptForMultisig(2, {uncompressedPubkey, pubkeys[1]});
239 :
240 : // Keystore does not have any keys
241 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
242 1 : BOOST_CHECK_EQUAL(result, ISMINE_NO);
243 :
244 : // Keystore has 1/2 keys
245 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(uncompressedKey));
246 :
247 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
248 1 : BOOST_CHECK_EQUAL(result, ISMINE_NO);
249 :
250 : // Keystore has 2/2 keys
251 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[1]));
252 :
253 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
254 1 : BOOST_CHECK_EQUAL(result, ISMINE_NO);
255 :
256 : // Keystore has 2/2 keys and the script
257 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(scriptPubKey));
258 :
259 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
260 1 : BOOST_CHECK_EQUAL(result, ISMINE_NO);
261 1 : }
262 :
263 : // P2SH multisig
264 : {
265 1 : CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
266 1 : keystore.SetupLegacyScriptPubKeyMan();
267 1 : LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
268 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(uncompressedKey));
269 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[1]));
270 :
271 1 : CScript redeemScript = GetScriptForMultisig(2, {uncompressedPubkey, pubkeys[1]});
272 1 : scriptPubKey = GetScriptForDestination(ScriptHash(redeemScript));
273 :
274 : // Keystore has no redeemScript
275 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
276 1 : BOOST_CHECK_EQUAL(result, ISMINE_NO);
277 :
278 : // Keystore has redeemScript
279 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(redeemScript));
280 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
281 1 : BOOST_CHECK_EQUAL(result, ISMINE_SPENDABLE);
282 1 : }
283 :
284 : // P2WSH multisig with compressed keys
285 : {
286 1 : CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
287 1 : keystore.SetupLegacyScriptPubKeyMan();
288 1 : LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
289 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
290 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[1]));
291 :
292 1 : CScript witnessScript = GetScriptForMultisig(2, {pubkeys[0], pubkeys[1]});
293 1 : scriptPubKey = GetScriptForDestination(WitnessV0ScriptHash(witnessScript));
294 :
295 : // Keystore has keys, but no witnessScript or P2SH redeemScript
296 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
297 1 : BOOST_CHECK_EQUAL(result, ISMINE_NO);
298 :
299 : // Keystore has keys and witnessScript, but no P2SH redeemScript
300 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(witnessScript));
301 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
302 1 : BOOST_CHECK_EQUAL(result, ISMINE_NO);
303 :
304 : // Keystore has keys, witnessScript, P2SH redeemScript
305 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(scriptPubKey));
306 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
307 1 : BOOST_CHECK_EQUAL(result, ISMINE_SPENDABLE);
308 1 : }
309 :
310 : // P2WSH multisig with uncompressed key
311 : {
312 1 : CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
313 1 : keystore.SetupLegacyScriptPubKeyMan();
314 1 : LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
315 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(uncompressedKey));
316 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[1]));
317 :
318 1 : CScript witnessScript = GetScriptForMultisig(2, {uncompressedPubkey, pubkeys[1]});
319 1 : scriptPubKey = GetScriptForDestination(WitnessV0ScriptHash(witnessScript));
320 :
321 : // Keystore has keys, but no witnessScript or P2SH redeemScript
322 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
323 1 : BOOST_CHECK_EQUAL(result, ISMINE_NO);
324 :
325 : // Keystore has keys and witnessScript, but no P2SH redeemScript
326 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(witnessScript));
327 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
328 1 : BOOST_CHECK_EQUAL(result, ISMINE_NO);
329 :
330 : // Keystore has keys, witnessScript, P2SH redeemScript
331 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(scriptPubKey));
332 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
333 1 : BOOST_CHECK_EQUAL(result, ISMINE_NO);
334 1 : }
335 :
336 : // P2WSH multisig wrapped in P2SH
337 : {
338 1 : CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
339 1 : keystore.SetupLegacyScriptPubKeyMan();
340 1 : LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
341 :
342 1 : CScript witnessScript = GetScriptForMultisig(2, {pubkeys[0], pubkeys[1]});
343 1 : CScript redeemScript = GetScriptForDestination(WitnessV0ScriptHash(witnessScript));
344 1 : scriptPubKey = GetScriptForDestination(ScriptHash(redeemScript));
345 :
346 : // Keystore has no witnessScript, P2SH redeemScript, or keys
347 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
348 1 : BOOST_CHECK_EQUAL(result, ISMINE_NO);
349 :
350 : // Keystore has witnessScript and P2SH redeemScript, but no keys
351 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(redeemScript));
352 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(witnessScript));
353 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
354 1 : BOOST_CHECK_EQUAL(result, ISMINE_NO);
355 :
356 : // Keystore has keys, witnessScript, P2SH redeemScript
357 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
358 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[1]));
359 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
360 1 : BOOST_CHECK_EQUAL(result, ISMINE_SPENDABLE);
361 1 : }
362 :
363 : // OP_RETURN
364 : {
365 1 : CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
366 1 : keystore.SetupLegacyScriptPubKeyMan();
367 1 : LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
368 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
369 :
370 1 : scriptPubKey.clear();
371 1 : scriptPubKey << OP_RETURN << ToByteVector(pubkeys[0]);
372 :
373 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
374 1 : BOOST_CHECK_EQUAL(result, ISMINE_NO);
375 1 : }
376 :
377 : // witness unspendable
378 : {
379 1 : CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
380 1 : keystore.SetupLegacyScriptPubKeyMan();
381 1 : LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
382 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
383 :
384 1 : scriptPubKey.clear();
385 1 : scriptPubKey << OP_0 << ToByteVector(ParseHex("aabb"));
386 :
387 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
388 1 : BOOST_CHECK_EQUAL(result, ISMINE_NO);
389 1 : }
390 :
391 : // witness unknown
392 : {
393 1 : CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
394 1 : keystore.SetupLegacyScriptPubKeyMan();
395 1 : LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
396 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
397 :
398 1 : scriptPubKey.clear();
399 1 : scriptPubKey << OP_16 << ToByteVector(ParseHex("aabb"));
400 :
401 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
402 1 : BOOST_CHECK_EQUAL(result, ISMINE_NO);
403 1 : }
404 :
405 : // Nonstandard
406 : {
407 1 : CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
408 1 : keystore.SetupLegacyScriptPubKeyMan();
409 1 : LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
410 1 : BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
411 :
412 1 : scriptPubKey.clear();
413 1 : scriptPubKey << OP_9 << OP_ADD << OP_11 << OP_EQUAL;
414 :
415 1 : result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
416 1 : BOOST_CHECK_EQUAL(result, ISMINE_NO);
417 1 : }
418 2 : }
419 :
420 89 : BOOST_AUTO_TEST_SUITE_END()
|