rpc: added getaddressbalance method using addressindex

This commit is contained in:
Braydon Fuller
2016-03-17 16:06:08 -04:00
committed by Braydon Fuller
parent 7dbbb79cec
commit 5bb6d69ff8
4 changed files with 80 additions and 17 deletions

View File

@@ -44,6 +44,10 @@ class AddressIndexTest(BitcoinTestFramework):
assert_equal(self.nodes[1].getbalance(), 0)
assert_equal(self.nodes[2].getbalance(), 0)
# Check that balances are correct
balance0 = self.nodes[1].getaddressbalance("2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br")
assert_equal(balance0['balance'], 0);
# Check p2pkh and p2sh address indexes
print "Testing p2pkh and p2sh address index..."
@@ -89,6 +93,10 @@ class AddressIndexTest(BitcoinTestFramework):
assert_equal(multitxids[4], txid2);
assert_equal(multitxids[5], txidb2);
# Check that balances are correct
balance0 = self.nodes[1].getaddressbalance("2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br")
assert_equal(balance0['balance'], 45 * 100000000);
# Check that outputs with the same address will only return one txid
print "Testing for txid uniqueness..."
addressHash = "6349a418fc4578d10a372b54b45c280cc8c4382f".decode("hex")
@@ -109,6 +117,10 @@ class AddressIndexTest(BitcoinTestFramework):
assert_equal(len(txidsmany), 4);
assert_equal(txidsmany[3], sent_txid);
# Check that balances are correct
balance0 = self.nodes[1].getaddressbalance("2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br")
assert_equal(balance0['balance'], 45 * 100000000 + 21);
print "Passed\n"