mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-12 01:42:01 +02:00
Merge #15831: test: Add test that addmultisigaddress fails for watchonly addresses
fab6a0a659 test: Add test that addmultisigaddress fails for watchonly addresses (MarcoFalke)
fad81d870a test: Fixup creatmultisig documentation and whitespace (MarcoFalke)
Pull request description:
Just to make sure this is not regressed on accidentally in the future
ACKs for commit fab6a0:
jonatack:
ACK fab6a0a659
Tree-SHA512: bf8dcbc752f8910902a995e55ce486621156aa01f112990344815c4aab980298dfecc108e78245a8986a00c3871338ad16fc818a1bce9dfc6b37b9c88851e39d
This commit is contained in:
commit
429a7cf34f
@ -1,12 +1,16 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2015-2018 The Bitcoin Core developers
|
# Copyright (c) 2015-2019 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
"""Test transaction signing using the signrawtransaction* RPCs."""
|
"""Test multisig RPCs"""
|
||||||
|
|
||||||
from test_framework.test_framework import BitcoinTestFramework
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
|
from test_framework.util import (
|
||||||
|
assert_raises_rpc_error,
|
||||||
|
)
|
||||||
import decimal
|
import decimal
|
||||||
|
|
||||||
|
|
||||||
class RpcCreateMultiSigTest(BitcoinTestFramework):
|
class RpcCreateMultiSigTest(BitcoinTestFramework):
|
||||||
def set_test_params(self):
|
def set_test_params(self):
|
||||||
self.setup_clean_chain = True
|
self.setup_clean_chain = True
|
||||||
@ -17,15 +21,17 @@ class RpcCreateMultiSigTest(BitcoinTestFramework):
|
|||||||
|
|
||||||
def get_keys(self):
|
def get_keys(self):
|
||||||
node0, node1, node2 = self.nodes
|
node0, node1, node2 = self.nodes
|
||||||
self.add = [node1.getnewaddress() for _ in range(self.nkeys)]
|
add = [node1.getnewaddress() for _ in range(self.nkeys)]
|
||||||
self.pub = [node1.getaddressinfo(a)["pubkey"] for a in self.add]
|
self.pub = [node1.getaddressinfo(a)["pubkey"] for a in add]
|
||||||
self.priv = [node1.dumpprivkey(a) for a in self.add]
|
self.priv = [node1.dumpprivkey(a) for a in add]
|
||||||
self.final = node2.getnewaddress()
|
self.final = node2.getnewaddress()
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
node0, node1, node2 = self.nodes
|
node0, node1, node2 = self.nodes
|
||||||
|
|
||||||
# 50 BTC each, rest will be 25 BTC each
|
self.check_addmultisigaddress_errors()
|
||||||
|
|
||||||
|
self.log.info('Generating blocks ...')
|
||||||
node0.generate(149)
|
node0.generate(149)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
|
||||||
@ -38,6 +44,15 @@ class RpcCreateMultiSigTest(BitcoinTestFramework):
|
|||||||
|
|
||||||
self.checkbalances()
|
self.checkbalances()
|
||||||
|
|
||||||
|
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)]
|
||||||
|
assert_raises_rpc_error(-5, 'no full public key for address', lambda: self.nodes[0].addmultisigaddress(nrequired=1, keys=addresses))
|
||||||
|
for a in addresses:
|
||||||
|
# Importing all addresses should not change the result
|
||||||
|
self.nodes[0].importaddress(a)
|
||||||
|
assert_raises_rpc_error(-5, 'no full public key for address', lambda: self.nodes[0].addmultisigaddress(nrequired=1, keys=addresses))
|
||||||
|
|
||||||
def checkbalances(self):
|
def checkbalances(self):
|
||||||
node0, node1, node2 = self.nodes
|
node0, node1, node2 = self.nodes
|
||||||
node0.generate(100)
|
node0.generate(100)
|
||||||
@ -97,5 +112,6 @@ class RpcCreateMultiSigTest(BitcoinTestFramework):
|
|||||||
txinfo = node0.getrawtransaction(tx, True, blk)
|
txinfo = node0.getrawtransaction(tx, True, blk)
|
||||||
self.log.info("n/m=%d/%d %s size=%d vsize=%d weight=%d" % (self.nsigs, self.nkeys, self.output_type, txinfo["size"], txinfo["vsize"], txinfo["weight"]))
|
self.log.info("n/m=%d/%d %s size=%d vsize=%d weight=%d" % (self.nsigs, self.nkeys, self.output_type, txinfo["size"], txinfo["vsize"], txinfo["weight"]))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
RpcCreateMultiSigTest().main()
|
RpcCreateMultiSigTest().main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user