How Can I Fetch the Real Balance of an XPUB with Python Bitcoinlib?

Goal

To create at least a watch only wallet functionality in python. I will incorporate sending sats in the future as well.

Detail

I have already shared the code (in Python) on my GitHub. Looking for some feedback and trying to clarify some concepts that I am missing.

You can give any ideas, but the specific questions I have are here. I am a total noob in the Bitcoin world, so some clarification would be appreciated.

Questions

  • Does the bitcoinlib Python library interface with the real Bitcoin blockchain? I understand there is something like a test chain where I can get free testing coins. But any tutorial on how to use it, specifically with the Python library?
  • I generated the seed words in data/seed.txt using Blue Wallet (BW), and the XPUB exposed by BW matches the one returned by CustomWallet.get_xpub method. But the receiving address from BW is not matching the CustomWallet.get_address method. What does it mean? I understand under an XPUB there are multiple (infinite?) receiving addresses, is that the reason?
  • If I send sats to an address generated by the CustomWallet.get_address, will it show up in my Blue wallet if initialised with the same seed? And vice versa?
  • Should wallet.transactions(include_new=True) give me the unconfirmed transactions? I have an unconfirmed transaction (on the real blockchain, I sent from my Trezor), but it is not showing up when I call the method with Python.
  • Should the Wallet.balance() method show the real balance in the wallet in the blockchain? I have transferred some amount into the wallet, that BW is showing, but my code says the balance is zero. What gives?
  • What would be the best way to test sending and receiving multiple transactions via code, resembling the real Blockchain's behaviour as much as possible but without wasting my sats?


from Recent Questions - Bitcoin Stack Exchange https://ift.tt/uhnIdN1
via IFTTT

Popular posts from this blog

Future of Bitcoin encryption and security in a QC era

Possible rollback due to lazy reveal in BRC20?

A way to recover scammed Bitcoin investment