How does one just query the balance of a Bitcoin address with armory? is there any calculations involved(like looping over tx history and sum up a balance) or can I just call it and print out a simple balance?
Im' sure a lot of programmers could benefit the solution to this question to write their own software to use armory for like making their own Blockchain.info website or w/e.
The code was in my example, but I guess my example was too long. So here's an extraction of it.
from armoryengine import *
cppWallet = Cpp.BtcWallet()
cppWallet.addAddress_1_( addrStr_to_hash160('1EbAUHsitefy3rSECh8eK2fdAWTUbpVUDN') ) # addrStr
TheBDM.registerWallet(cppWallet)
BDM_LoadBlockchainFile()
TheBDM.scanBlockchainForTx(cppWallet)
fullBalance = cppWallet.getFullBalance()
print '\n\nBalance of this wallet:', coin2str(fullBalance)
etotheipi, say I want to avoid loading the blockchain file every time I want to use a Python program to find the balance of a bunch of addresses, what would be the appropriate way of doing this?
I have some code where I want to be able to query balances as quickly as possible, and would prefer not to wait while loading the now 3 GB block chain.
This way doesn't work for me. The first scan works fine, but the second scan hangs at TheBDM.scanBlockchainForTx(cppWallet).
from armoryengine import *
def init()
BDM_LoadBlockchainFile()
def get_balance(addresses)
cppWallet = Cpp.BtcWallet()
for address in addresses:
cppWallet.addAddress_1_( address )
TheBDM.registerWallet(cppWallet)
TheBDM.scanBlockchainForTx(cppWallet)
fullBalance = cppWallet.getFullBalance()
TheBDM.unregisterWallet(cppWallet)
return fullBalance
Here's the gdb output from attaching to the python process.
(gdb) where
#0 0x00007f1728fc7980 in free@plt () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#1 0x00007f1729426f4a in BtcWallet::scanTx(Tx&, unsigned int, unsigned int, unsigned int) () from /home/rune/Programming/BitcoinArmory/_CppBlockUtils.so
#2 0x00007f172942ad3a in BlockDataManager_FileRefs::scanRegisteredTxForWallet(BtcWallet&, unsigned int, unsigned int) () from /home/rune/Programming/BitcoinArmory/_CppBlockUtils.so
#3 0x00007f172942b09d in BlockDataManager_FileRefs::scanBlockchainForTx(BtcWallet&, unsigned int, unsigned int) () from /home/rune/Programming/BitcoinArmory/_CppBlockUtils.so
#4 0x00007f172950cc12 in _wrap_BlockDataManager_FileRefs_scanBlockchainForTx () from /home/rune/Programming/BitcoinArmory/_CppBlockUtils.so
#5 0x000000000049c4d8 in PyEval_EvalFrameEx ()
#6 0x000000000049f1c0 in PyEval_EvalCodeEx ()
#7 0x00000000004983b8 in PyEval_EvalFrameEx ()
#8 0x000000000049f1c0 in PyEval_EvalCodeEx ()
#9 0x00000000004a9081 in PyRun_FileExFlags ()
#10 0x00000000004a9311 in PyRun_SimpleFileExFlags ()
#11 0x00000000004aa8bd in Py_Main ()
#12 0x00007f172a7a476d in __libc_start_main () from /lib/x86_64-linux-gnu/libc.so.6
#13 0x000000000041b9b1 in _start ()
So I guess I'd like to know:
- What's the right way to make the library load the blockchain in advance, so it's always ready to process new addresses?
- How do I properly make "TheBDM" forget the old addresses that were loaded via registerWallet? I'm just guessing unregisterWallet will do it, but I don't know. Is resetRegisteredWallets necessary as well?