mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-08-29 00:00:26 +02:00
Merge bitcoin/bitcoin#32721: wallet, rpc: Remove deprecated balances from getwalletinfo and getunconfirmedbalance
c3fe85e2d6
wallet, rpc, test: Remove deprecated getunconfirmedbalance (Ava Chow)0ec255139b
wallet, rpc: Remove deprecated balances from getwalletinfo (Ava Chow) Pull request description: `getwalletinfo` result fields `balance`, `immature_balance`, and `unconfirmed_balance`, and the `getunconfirmedbalance` RPC have all been deprecated since 0.19.0. It's been long enough that they should either be removed or undeprecated. The functionality provided by these RPCs is provided by `getbalances`. ACKs for top commit: davidgumberg: ACKc3fe85e2d6
rkrux: ACKc3fe85e2d6
BrandonOdiwuor: ACKc3fe85e2d6
removing the deprecated `balance, unconfirmed_balance, immature_balance` fields from `getwalletinfo` and `getunconfirmedbalance` RPCs, as this infomation can be found on the `getbalances` RPC w0xlt: reACKc3fe85e2d6
Tree-SHA512: c7c4acfd9cabc7517ba813b95281a6c6a717a417312afd9346298669b4f7bd37724ad977148ce42db7fd47fc3d1f5a8482d8ff2e7b9cb74756b171a5b8b91ef2
This commit is contained in:
@@ -167,12 +167,6 @@ class WalletTest(BitcoinTestFramework):
|
||||
# TODO: fix getbalance tracking of coin spentness depth
|
||||
assert_equal(self.nodes[0].getbalance(minconf=1), Decimal('0'))
|
||||
assert_equal(self.nodes[1].getbalance(minconf=1), Decimal('0'))
|
||||
# getunconfirmedbalance
|
||||
assert_equal(self.nodes[0].getunconfirmedbalance(), Decimal('60')) # output of node 1's spend
|
||||
assert_equal(self.nodes[1].getunconfirmedbalance(), Decimal('30') - fee_node_1) # Doesn't include output of node 0's send since it was spent
|
||||
# getwalletinfo.unconfirmed_balance
|
||||
assert_equal(self.nodes[0].getwalletinfo()["unconfirmed_balance"], Decimal('60'))
|
||||
assert_equal(self.nodes[1].getwalletinfo()["unconfirmed_balance"], Decimal('30') - fee_node_1)
|
||||
|
||||
test_balances(fee_node_1=Decimal('0.01'))
|
||||
|
||||
|
@@ -69,9 +69,9 @@ class WalletTest(BitcoinTestFramework):
|
||||
|
||||
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
|
||||
|
||||
walletinfo = self.nodes[0].getwalletinfo()
|
||||
assert_equal(walletinfo['immature_balance'], 50)
|
||||
assert_equal(walletinfo['balance'], 0)
|
||||
balances = self.nodes[0].getbalances()
|
||||
assert_equal(balances["mine"]["immature"], 50)
|
||||
assert_equal(balances["mine"]["trusted"], 0)
|
||||
|
||||
self.sync_all(self.nodes[0:3])
|
||||
self.generate(self.nodes[1], COINBASE_MATURITY + 1, sync_fun=lambda: self.sync_all(self.nodes[0:3]))
|
||||
@@ -118,8 +118,7 @@ class WalletTest(BitcoinTestFramework):
|
||||
# but 10 will go to node2 and the rest will go to node0
|
||||
balance = self.nodes[0].getbalance()
|
||||
assert_equal(set([txout1['value'], txout2['value']]), set([10, balance]))
|
||||
walletinfo = self.nodes[0].getwalletinfo()
|
||||
assert_equal(walletinfo['immature_balance'], 0)
|
||||
assert_equal(self.nodes[0].getbalances()["mine"]["immature"], 0)
|
||||
|
||||
# Have node0 mine a block, thus it will collect its own fee.
|
||||
self.generate(self.nodes[0], 1, sync_fun=lambda: self.sync_all(self.nodes[0:3]))
|
||||
|
@@ -203,8 +203,7 @@ class MultiWalletTest(BitcoinTestFramework):
|
||||
self.nodes[0].loadwallet("w5")
|
||||
assert_equal(set(node.listwallets()), {"w4", "w5"})
|
||||
w5 = wallet("w5")
|
||||
w5_info = w5.getwalletinfo()
|
||||
assert_equal(w5_info['immature_balance'], 50)
|
||||
assert_equal(w5.getbalances()["mine"]["immature"], 50)
|
||||
|
||||
competing_wallet_dir = os.path.join(self.options.tmpdir, 'competing_walletdir')
|
||||
os.mkdir(competing_wallet_dir)
|
||||
@@ -226,7 +225,7 @@ class MultiWalletTest(BitcoinTestFramework):
|
||||
self.generatetoaddress(node, nblocks=1, address=wallets[0].getnewaddress(), sync_fun=self.no_op)
|
||||
for wallet_name, wallet in zip(wallet_names, wallets):
|
||||
info = wallet.getwalletinfo()
|
||||
assert_equal(info['immature_balance'], 50 if wallet is wallets[0] else 0)
|
||||
assert_equal(wallet.getbalances()["mine"]["immature"], 50 if wallet is wallets[0] else 0)
|
||||
assert_equal(info['walletname'], wallet_name)
|
||||
|
||||
# accessing invalid wallet fails
|
||||
|
@@ -100,7 +100,7 @@ class ReorgsRestoreTest(BitcoinTestFramework):
|
||||
# Restart to ensure node and wallet are flushed
|
||||
self.restart_node(0)
|
||||
wallet = node.get_wallet_rpc("reorg_crash")
|
||||
assert_greater_than(wallet.getwalletinfo()['immature_balance'], 0)
|
||||
assert_greater_than(wallet.getbalances()["mine"]["immature"], 0)
|
||||
|
||||
# Disconnect tip and sync wallet state
|
||||
tip = wallet.getbestblockhash()
|
||||
@@ -108,7 +108,7 @@ class ReorgsRestoreTest(BitcoinTestFramework):
|
||||
wallet.syncwithvalidationinterfacequeue()
|
||||
|
||||
# Tip was disconnected, ensure coinbase has been abandoned
|
||||
assert_equal(wallet.getwalletinfo()['immature_balance'], 0)
|
||||
assert_equal(wallet.getbalances()["mine"]["immature"], 0)
|
||||
coinbase_tx_id = wallet.getblock(tip, verbose=1)["tx"][0]
|
||||
assert_equal(wallet.gettransaction(coinbase_tx_id)['details'][0]['abandoned'], True)
|
||||
|
||||
@@ -131,12 +131,12 @@ class ReorgsRestoreTest(BitcoinTestFramework):
|
||||
assert(node.getbestblockhash() != tip)
|
||||
# Ensure wallet state is consistent now
|
||||
assert_equal(wallet.gettransaction(coinbase_tx_id)['details'][0]['abandoned'], True)
|
||||
assert_equal(wallet.getwalletinfo()['immature_balance'], 0)
|
||||
assert_equal(wallet.getbalances()["mine"]["immature"], 0)
|
||||
|
||||
# And finally, verify the state if the block ends up being into the best chain again
|
||||
node.reconsiderblock(tip)
|
||||
assert_equal(wallet.gettransaction(coinbase_tx_id)['details'][0]['abandoned'], False)
|
||||
assert_greater_than(wallet.getwalletinfo()['immature_balance'], 0)
|
||||
assert_greater_than(wallet.getbalances()["mine"]["immature"], 0)
|
||||
|
||||
def run_test(self):
|
||||
# Send a tx from which to conflict outputs later
|
||||
|
Reference in New Issue
Block a user