From a43be5bcdb27a68abe9bb5fec57185a1b6652479 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Tue, 7 Mar 2017 09:50:41 +0100 Subject: rpc: Prevent `dumpwallet` from overwriting files Prevent arbitrary files from being overwritten. There have been reports that users have overwritten wallet files this way. It may also avoid other security issues. Fixes #9934. Adds mention to release notes and adds a test. Github-Pull: #9937 Rebased-From: 0cd9273fd959c6742574259d026039f7da0309a2 --- test/functional/wallet-dump.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'test/functional') diff --git a/test/functional/wallet-dump.py b/test/functional/wallet-dump.py index 569cc46e6c..016bd95925 100755 --- a/test/functional/wallet-dump.py +++ b/test/functional/wallet-dump.py @@ -7,7 +7,7 @@ import os from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import assert_equal +from test_framework.util import (assert_equal, assert_raises_jsonrpc) def read_dump(file_name, addrs, hd_master_addr_old): @@ -108,5 +108,8 @@ class WalletDumpTest(BitcoinTestFramework): assert_equal(found_addr_chg, 90*2 + 50) # old reserve keys are marked as change now assert_equal(found_addr_rsv, 90*2) + # Overwriting should fail + assert_raises_jsonrpc(-8, "already exists", self.nodes[0].dumpwallet, tmpdir + "/node0/wallet.unencrypted.dump") + if __name__ == '__main__': WalletDumpTest().main () -- cgit v1.2.3 From 405e069d3b8c71b0f5161d9dfb2334a0bb988f2e Mon Sep 17 00:00:00 2001 From: Dusty Williams Date: Sun, 8 Oct 2017 23:18:48 -0400 Subject: Update importprivkey named args documentation Fixes #11462. Updated documentation for importprivkey function to use the correct name for the first argument. Also updates a call to importprivkey to use named args in functional test. Github-Pull: #11465 Rebased-From: aa57590d7c5eab1df5443e8ac9ed53ad0db46c02 --- test/functional/importprunedfunds.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/functional') diff --git a/test/functional/importprunedfunds.py b/test/functional/importprunedfunds.py index 94753fe431..198a2058aa 100755 --- a/test/functional/importprunedfunds.py +++ b/test/functional/importprunedfunds.py @@ -82,8 +82,8 @@ class ImportPrunedFundsTest(BitcoinTestFramework): assert_equal(balance2, Decimal('0.05')) #Import with private key with no rescan - self.nodes[1].importprivkey(address3_privkey, "add3", False) - result3 = self.nodes[1].importprunedfunds(rawtxn3, proof3) + self.nodes[1].importprivkey(privkey=address3_privkey, label="add3", rescan=False) + self.nodes[1].importprunedfunds(rawtxn3, proof3) balance3 = self.nodes[1].getbalance("add3", 0, False) assert_equal(balance3, Decimal('0.025')) balance3 = self.nodes[1].getbalance("*", 0, True) -- cgit v1.2.3 From 20cdc2b36c40221a0eec942a1fbdf38ca7c4e005 Mon Sep 17 00:00:00 2001 From: Pedro Branco Date: Wed, 11 Oct 2017 11:12:59 +0100 Subject: Fix importmulti bug when importing an already imported key Github-Pull: #11483 Rebased-From: a44a215177ab55b4a3b36a7980c313e908e2dd18 --- test/functional/importmulti.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/functional') diff --git a/test/functional/importmulti.py b/test/functional/importmulti.py index e83e85de13..783f06f912 100755 --- a/test/functional/importmulti.py +++ b/test/functional/importmulti.py @@ -170,6 +170,18 @@ class ImportMultiTest (BitcoinTestFramework): assert_equal(address_assert['ismine'], True) assert_equal(address_assert['timestamp'], timestamp) + self.log.info("Should not import an address with private key if is already imported") + result = self.nodes[1].importmulti([{ + "scriptPubKey": { + "address": address['address'] + }, + "timestamp": "now", + "keys": [ self.nodes[0].dumpprivkey(address['address']) ] + }]) + assert_equal(result[0]['success'], False) + assert_equal(result[0]['error']['code'], -4) + assert_equal(result[0]['error']['message'], 'The wallet already contains the private key for this address or script') + # Address + Private key + watchonly self.log.info("Should not import an address with private key and with watchonly") address = self.nodes[0].validateaddress(self.nodes[0].getnewaddress()) -- cgit v1.2.3