petertodd / python-bitcoinlib

Python3 library providing an easy interface to the Bitcoin data structures and protocol.
Other
1.81k stars 620 forks source link

Bitcoind forces to register an address in order to be checked #214

Closed Moliholy closed 4 years ago

Moliholy commented 4 years ago

When using bitcoinilb's HDWallet implementation with bitcoind, I've realized that I was forced firstly register the addresses I was interested in, otherwise it'll return an error.

For the sake of completeness, here's the code:

def update() -> None:
        addresses = wallet.addresslist(account_id=0)
        registered_addresses = set(map(lambda a: a['address'],
                                       bitcoind_execute('listreceivedbyaddress', params=[0, True, True])))
        addresses_to_update = filter(lambda a: a not in registered_addresses, addresses)
        for address in addresses_to_update:
            bitcoind_execute('importaddress', params=[address, '', False])
       wallet.utxos_update(account_id=0, networks=[wallet.network.name])

As you can see, if I wouldn't call the importaddress bitcoind method it wouldn't work. Furthermore, if I wouldn't call the listreceivedbyaddress method I'd be calling more times than needed to my bitcoind node. Is this the expected behaviour, or am I missing something?

Moliholy commented 4 years ago

My apologies, this issue should've been opened in https://github.com/1200wd/bitcoinlib, but they both have very similar names and I mixed them up.