MetacoSA / NBitcoin

Comprehensive Bitcoin library for the .NET framework.
MIT License
1.88k stars 847 forks source link

SPV wallet (database integration) #274

Closed ghost closed 6 years ago

ghost commented 7 years ago

Hello,

is there a simple way to store public/private key pairs and address hashes not only as JSON but also in a database? I want to store all the data which is currently stored as JSON in a database. JSON is not so appropiate when dealing with many bitcoin addresses.

Regards Martin

NicolasDorier commented 7 years ago

There is no way, but your can easily adapt my code to work on database. Just copy/paste the TrackerBehavior and SPVWallet, and use a DB instead of JSON file.

The problem is that SPV bloom filters are limited to a certain number of tracked address, because of the max size of the loaded bloom filter. (I think it is around 10 000)

Which mean, if you want to make your own address tracking service, the best is to download full blocks and scan tracked addresses from it.

This is exactly what I have done with this project https://github.com/Dgarage/ElementsExplorer except it is using Elements and not Bitcoin.

I will probably make a bitcoin version in near futrue, but meanwhile you can use it and adapt it for bitcoin.

ghost commented 7 years ago

Hi Nicolas,

so the bloom filters in the bitcoin system are intrinsically limited, if i got it right?

You have coded a NBitcoin.Indexer. How about that?

As far i understand, i can replace the SPV wallet completely by a full block chain indexer which polls from time to time to circumvent the bloom filter problem? Is the speed a concern here? Does it take hours to parse the block chain with your indexer?

Regards Martin

NicolasDorier commented 7 years ago

@maddin123 please wait 1 or 2 more days, I just created a new project to make it more easy. Will publish soon.

ghost commented 7 years ago

Thx!

NicolasDorier commented 7 years ago

Ok so take a look at https://github.com/dgarage/NBXplorer . Note this is a relatively new project, I will provide things to make it more easy to use with NBitcoin soon. However you have all your need, namely, a ExplorerClient.Sync which sends you the UTXOs from a HD pubkey.

Try it, if you find any issue on this, let me know in the issues tracker there.

ghost commented 7 years ago

Hello Nicolas,

have some probs! Pls see issue tracker @NBXplorer. Problem: it does not work with neither TestNet nor with Main net. Always get connection refused or not understood. I use the latest BicoinCore client.

NBitcoin with Node.Connect(Network.TestNet, "127.0.0.1:18333") works!

Regards Martin

NicolasDorier commented 7 years ago

Can you try again ?

NicolasDorier commented 7 years ago

git pull before trying, don't forget to run dotnet run -testnet

NicolasDorier commented 6 years ago

Closing, redirected https://github.com/dgarage/NBXplorer/issues/1