transactions – Manually checking for credited bitcoins

0
72


If I’ve the bitcoin tackle, the personal key and a transaction ID from Bitcoin (regtest mode) in shell variables, what Python code do I must run to assert the Bitcoins are certainly supposed for this personal key?

I’ve been following this wonderful article – Bitcoins the arduous approach : Utilizing the uncooked Bitcoin protocol. I hope to duplicate this with Bitcoin in regtest mode as half of a bigger design.

To start with, I had to make sure that the code talked about within the article (obtainable right here) can generate Bitcoin tackle with m or n because the prefix and makes use of 111 because the community ID. See right here. I made the next code modifications to generate addresses for regtest mode:

keyUtils.pubKeyToAddr


def pubKeyToAddr(s):
ripemd160 = hashlib.new('ripemd160')
ripemd160.replace(hashlib.sha256(s.decode('hex')).digest())
return utils.base58CheckEncode(111, ripemd160.digest())

utils.base58CheckEncode


def base58CheckEncode(model, payload):
s = chr(model) + payload
checksum = hashlib.sha256(hashlib.sha256(s).digest()).digest()[0:4]
consequence = s + checksum
leadingZeros = countLeadingChars(consequence, '')
return 'm' * leadingZeros + base58encode(base256decode(consequence))

Then, with bitcoin-qt, I transferred some BTC to an tackle generated from above. The switch goes by means of and is confirmed when a brand new block is created.

Nonetheless, I’m unable to see the quantity credited to this new tackle with the getreceivedbyaddress command. I’m working this command within the Debug Window console (for some purpose, bitcoin-cli would not join even after configuring bitcoind). I believe, the rationale may very well be the truth that, the personal key and the bitcoin tackle was generated elsewhere from command line relatively than the default --data-dir location that bitcoin-qt used when it was launched. I perceive this.

LEAVE A REPLY

Please enter your comment!
Please enter your name here