mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-04 20:51:27 +02:00
Test sortedmulti descriptor using BIP 67 tests
This commit is contained in:
@ -4,6 +4,7 @@
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
"""Test multisig RPCs"""
|
||||
|
||||
from test_framework.descriptors import descsum_create
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import (
|
||||
assert_raises_rpc_error,
|
||||
@ -14,6 +15,8 @@ from test_framework.key import ECPubKey
|
||||
import binascii
|
||||
import decimal
|
||||
import itertools
|
||||
import json
|
||||
import os
|
||||
|
||||
class RpcCreateMultiSigTest(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
@ -72,6 +75,18 @@ class RpcCreateMultiSigTest(BitcoinTestFramework):
|
||||
assert_equal(legacy_addr, node0.addmultisigaddress(2, keys, '', 'bech32')['address'])
|
||||
assert_equal(legacy_addr, node0.addmultisigaddress(2, keys, '', 'p2sh-segwit')['address'])
|
||||
|
||||
self.log.info('Testing sortedmulti descriptors with BIP 67 test vectors')
|
||||
with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data/rpc_bip67.json'), encoding='utf-8') as f:
|
||||
vectors = json.load(f)
|
||||
|
||||
for t in vectors:
|
||||
key_str = ','.join(t['keys'])
|
||||
desc = descsum_create('sh(sortedmulti(2,{}))'.format(key_str))
|
||||
assert_equal(self.nodes[0].deriveaddresses(desc)[0], t['address'])
|
||||
sorted_key_str = ','.join(t['sorted_keys'])
|
||||
sorted_key_desc = descsum_create('sh(multi(2,{}))'.format(sorted_key_str))
|
||||
assert_equal(self.nodes[0].deriveaddresses(sorted_key_desc)[0], t['address'])
|
||||
|
||||
def check_addmultisigaddress_errors(self):
|
||||
self.log.info('Check that addmultisigaddress fails when the private keys are missing')
|
||||
addresses = [self.nodes[1].getnewaddress(address_type='legacy') for _ in range(2)]
|
||||
|
Reference in New Issue
Block a user