NBitcoin, how to implement wallet restoration? How does it work?
at first sorry for my ignorance, I have little experience at bitcoin programming.
Im trying to implement a very simple wallet using NBitcoin library. I have done some work, but now Im stucked with wallet restoration function.
Lets say I have mnemonic private key, then I calculate its public key.
With public key am I able to track all transactions associated with this key? Even if I used multiple adresses? How its done(NBitcoin)? Any advice? Do I have to iterate throught whole blockchain and chceck signatures?
Thank you.
Top Answer/Comment:
With public key am I able to track all transactions associated with this key?
A public key has two corresponding addresses: Uncompressed and compressed. I suggest only generating compressed public keys for simplicity. The relevant methods are Compress and Decompress here.
So, yes.
Even if I used multiple adresses?
Multiple addresses: Yes, you should track all of them.
Do I have to iterate throughout whole blockchain and check the signatures?
You should use SPV: Download a block, verify it, keep the headers, skip to the next block. Also you should keep the transactions that are incoming/outgoing. Writing the current block height to the wallet file is a good idea, as after you launch the wallet for the second time, you'll only need to download blocks and scan for relevant transactions after that block height.
상단 광고의 [X] 버튼을 누르면 내용이 보입니다