Skip to content

Commit 6583737

Browse files
committed
Merge #8581: [wallet] rpc: Drop misleading option
fab5ecb [wallet] rpc: Drop misleading option (MarcoFalke)
2 parents c19f8a4 + fab5ecb commit 6583737

File tree

3 files changed

+22
-28
lines changed

3 files changed

+22
-28
lines changed

doc/release-notes.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ report issues about Windows XP to the issue tracker.
4141
Notable changes
4242
===============
4343

44+
Low-level RPC changes
45+
----------------------
46+
47+
- `importprunedfunds` only accepts two required arguments. Some versions accept
48+
an optional third arg, which was always ignored. Make sure to never pass more
49+
than two arguments.
50+
51+
4452
0.14.0 Change log
4553
=================
4654

qa/rpc-tests/importprunedfunds.py

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,10 @@ def setup_network(self, split=False):
2020
self.is_network_split=False
2121
self.sync_all()
2222

23-
def run_test (self):
24-
import time
25-
begintime = int(time.time())
26-
23+
def run_test(self):
2724
print("Mining blocks...")
2825
self.nodes[0].generate(101)
2926

30-
# sync
3127
self.sync_all()
3228

3329
# address
@@ -72,7 +68,6 @@ def run_test (self):
7268
rawtxn2 = self.nodes[0].gettransaction(txnid2)['hex']
7369
proof2 = self.nodes[0].gettxoutproof([txnid2])
7470

75-
7671
txnid3 = self.nodes[0].sendtoaddress(address3, 0.025)
7772
self.nodes[0].generate(1)
7873
rawtxn3 = self.nodes[0].gettransaction(txnid3)['hex']
@@ -82,28 +77,27 @@ def run_test (self):
8277

8378
#Import with no affiliated address
8479
try:
85-
result1 = self.nodes[1].importprunedfunds(rawtxn1, proof1, "")
80+
self.nodes[1].importprunedfunds(rawtxn1, proof1)
8681
except JSONRPCException as e:
8782
assert('No addresses' in e.error['message'])
8883
else:
8984
assert(False)
9085

91-
9286
balance1 = self.nodes[1].getbalance("", 0, True)
9387
assert_equal(balance1, Decimal(0))
9488

9589
#Import with affiliated address with no rescan
96-
self.nodes[1].importaddress(address2, "", False)
97-
result2 = self.nodes[1].importprunedfunds(rawtxn2, proof2, "")
98-
balance2 = Decimal(self.nodes[1].getbalance("", 0, True))
90+
self.nodes[1].importaddress(address2, "add2", False)
91+
result2 = self.nodes[1].importprunedfunds(rawtxn2, proof2)
92+
balance2 = self.nodes[1].getbalance("add2", 0, True)
9993
assert_equal(balance2, Decimal('0.05'))
10094

10195
#Import with private key with no rescan
102-
self.nodes[1].importprivkey(address3_privkey, "", False)
103-
result3 = self.nodes[1].importprunedfunds(rawtxn3, proof3, "")
104-
balance3 = Decimal(self.nodes[1].getbalance("", 0, False))
96+
self.nodes[1].importprivkey(address3_privkey, "add3", False)
97+
result3 = self.nodes[1].importprunedfunds(rawtxn3, proof3)
98+
balance3 = self.nodes[1].getbalance("add3", 0, False)
10599
assert_equal(balance3, Decimal('0.025'))
106-
balance3 = Decimal(self.nodes[1].getbalance("", 0, True))
100+
balance3 = self.nodes[1].getbalance("*", 0, True)
107101
assert_equal(balance3, Decimal('0.075'))
108102

109103
#Addresses Test - after import
@@ -118,26 +112,23 @@ def run_test (self):
118112
assert_equal(address_info['ismine'], True)
119113

120114
#Remove transactions
121-
122115
try:
123116
self.nodes[1].removeprunedfunds(txnid1)
124117
except JSONRPCException as e:
125118
assert('does not exist' in e.error['message'])
126119
else:
127120
assert(False)
128121

129-
130-
balance1 = Decimal(self.nodes[1].getbalance("", 0, True))
122+
balance1 = self.nodes[1].getbalance("*", 0, True)
131123
assert_equal(balance1, Decimal('0.075'))
132124

133-
134125
self.nodes[1].removeprunedfunds(txnid2)
135-
balance2 = Decimal(self.nodes[1].getbalance("", 0, True))
126+
balance2 = self.nodes[1].getbalance("*", 0, True)
136127
assert_equal(balance2, Decimal('0.025'))
137128

138129
self.nodes[1].removeprunedfunds(txnid3)
139-
balance3 = Decimal(self.nodes[1].getbalance("", 0, True))
130+
balance3 = self.nodes[1].getbalance("*", 0, True)
140131
assert_equal(balance3, Decimal('0.0'))
141132

142133
if __name__ == '__main__':
143-
ImportPrunedFundsTest ().main ()
134+
ImportPrunedFundsTest().main()

src/wallet/rpcdump.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -257,14 +257,13 @@ UniValue importprunedfunds(const UniValue& params, bool fHelp)
257257
if (!EnsureWalletIsAvailable(fHelp))
258258
return NullUniValue;
259259

260-
if (fHelp || params.size() < 2 || params.size() > 3)
260+
if (fHelp || params.size() != 2)
261261
throw runtime_error(
262262
"importprunedfunds\n"
263263
"\nImports funds without rescan. Corresponding address or script must previously be included in wallet. Aimed towards pruned wallets. The end-user is responsible to import additional transactions that subsequently spend the imported outputs or rescan after the point in the blockchain the transaction is included.\n"
264264
"\nArguments:\n"
265265
"1. \"rawtransaction\" (string, required) A raw transaction in hex funding an already-existing address in wallet\n"
266266
"2. \"txoutproof\" (string, required) The hex output from gettxoutproof that contains the transaction\n"
267-
"3. \"label\" (string, optional) An optional label\n"
268267
);
269268

270269
CTransaction tx;
@@ -277,10 +276,6 @@ UniValue importprunedfunds(const UniValue& params, bool fHelp)
277276
CMerkleBlock merkleBlock;
278277
ssMB >> merkleBlock;
279278

280-
string strLabel = "";
281-
if (params.size() == 3)
282-
strLabel = params[2].get_str();
283-
284279
//Search partial merkle tree in proof for our transaction and index in valid block
285280
vector<uint256> vMatch;
286281
vector<unsigned int> vIndex;

0 commit comments

Comments
 (0)