I just thought I'd jot down a few notes on the experience of trying out the current NTumbleBit
This is testing on regtest, done for the simple reason that you don't have to wait for testnet blocks (nor sync testnet which is mildly annoying). At this stage I just wanted to learn how this works.
Your starting point is this wiki page
You need to download Bitcoin Core. Use at least 0.13.1
- this turned out to be only major blocking point in the whole test, funnily enough, for me - it took me a few hours(!) in debugging to realize that the reason my wallet's coins were not being recognized was simply because 0.12.1 didn't support the necessary RPC syntax. (Note to devs: is there a way to expose errors/exception to the user in the client to help with under-the-hood errors like that? RPC configuration errors are
exposed, so that's good of course).
Since this is regtest, that's it: you don't need to sync any blockchains :)
However, you do of course have to configure and start it. Put a bitcoin.conf somewhere (if you're currently running a node it's easiest to make a separate one from your main ~/.bitcoin/bitcoin.conf one, of course. I put one in ~/bitcoin.conf with these settings:
(you'll need those values again in a minute) and then run with
~/bitcoininstallationdibitcoind -regtest -daemon -conf=homedibitcoin.conf
(I didn't need to add server=1 to config).
Note that coins are not available until maturity, so you need to use the generate command to mine blocks, like this:
~/bitcoininstallationdibitcoin-cli -regtest -rpcuser=bitcoinrpc -rpcpassword=123456abcdef generate 101
Now your regtest bitcoind is running, you can move on to Tumblebit. Follow the instructions in the wiki page mentioned at the start; install .Net Core - the Microsoft instructions are easy to follow, just a couple of apt-gets and install the *.deb. Next, clone the github repo and run the Unit Tests. They passed first time for me.
Next, start up the server, following the instructions in the wiki, except note you're using regtest, so:
cd NTumbleBit.TumblerServer dotnet run -regtest
The first start up will compile but also set up RSA keys, all that is fine without changes, but you'll need to edit the config so that the RPC is pointing at your regtest instance properly. In this case it (the new config should be located in ~/.ntumblebit/RegTest/server.config) should be edited to look like:
rpc.url=http://localhost:18332/ rpc.user=bitcoinrpc rpc.password=123456abcdef #rpc.cookiefile=yourbitcoinfolde.cookie
Then restart and check you get no RPC errors. Leave that console open, it's running a server loop.
Next, configure and start the client. Note, we are still following the wiki page, except for the regtest element, so:
cd NTumbleBit.CLI dotnet run -regtest
You'll most likely get an RPC error again, before it shuts down. Now we need to edit the ~/.ntumblebit/RegTest/client.config file. The server can be left as the default localhost:5000, but you need the right RPC settings:
rpc.url=http://localhost:18332/ rpc.user=bitcoinrpc rpc.password=123456abcdef #rpc.cookiefile=yourbitcoinfolde.cookie tumbler.server=http://localhost:5000 outputwallet.extpubkey= outputwallet.keypath=0
the last two fields are the important bit, which the wiki page explains in some detail for the testnet case.
Details on setting up a receiving wallet (for this test!)
What you need is a BIP32 based wallet (HD) that supports testnet, and can be run against regtest here (which in most cases will be the same thing to a wallet, as long as it can connect via RPC to sync itself). The good news is the wallet doesn't need to contain any coins. The details of the following probably won't be suitable for most (if you've never used joinmarket it's a bit convoluted), so you'll probably want to find another easy to use wallet; the wiki page should be a good starting point.
For my test I used joinmarket; all we need to do is (a) hook it up to the regtest instance, and (b) extract the BIP32 xpub key that we'll be sending coins to. So in my case the flow of coins is:
Regtest Bitcoin Core wallet (containing 'mined' coins) one branch of my BIP32 joinmarket wallet, configured to sync against the same regtest instance.
I used my new joinmarket code
but it's the same for the main joinmarket code
. I overwrote joinmarket.cfg to have regtest settings (use this file
; only the highlighted settings matter, those are the right ones for this test), then just run python wallet-tool.py randomseed. "randomseed" there can be literally anything, it's read as a brainwallet style seed for the bip32 wallet (because testnet, we don't care about its insecurity). The tpub.. keys seen for each branch are the "xpub" public keys at that branch of the BIP32 wallet. Tumblebit is going to send to a branch below
whatever xpub we need, so the simplest is to add a print statement to print the xpub key above
that; e.g. add this code:
for i in range(max_mix_depth): print('master for index: ' + str( i) + ' : ' + btc.bip32_privtopub(mixing_depth_keys[i]))
immediately above this
line. Then run again python wallet-tool.py randomseed.
Extract an xpub for any one of the "mixdepths", e.g. I chose:
master for index: 3 : tpubDBFGvUbWtEPKXeWPeG7rUh98iV9GuXSDbnk6ZrZHjcmp134BPByT293HPPQ93DktrVFKpZeAU1ULSdyfmwWuUGvUVLP19JkdUq2mzNKFJPR
and put that tpub.. key into the field pubkey in the above mentioned 'client.config':
Now save and quit.
Running the tumble
Restart the client. If RPC is right, it'll start running, waiting for blocks. Your regtest Core instance will have coins (after the previous generate 101), and those coins will be automatically tumbled, one coin at a time, into the output wallet (in my case, the branch m/0/3/0 which is labelled there 'mixdepth 3, external').
Now you can test and watch the process! Open up a third console and repeatedly generate blocks:
/path/to/bitcoin/bin/bitcoin-cli -regtest -rpcpassword=123456abcdef generate 1
As each block is generated you'll see the state in the client terminal window updating, showing the phases. A new 'epoch' (right term?) is started every N blocks (I haven't investigated the timing yet), and several epochs run concurrently. In each one, the client can pay in 1 Bitcoin (from Core) and eventually get out 1 coin - fees to the destination (Joinmarket in my case, any other BIP32 in yours). You can replace generate 1 with generate N but I'm not sure if the code will always correctly handle you mining lots of blocks at once! After a large enough number of blocks you'll start to see 'ClientCashout phase' occurring, and txids being printed out. You can go back to your (JM or other) wallet and see the coins arriving; here's what I see after a few epochs have gone through (using my python wallet-tool.py randomseed command):
for mixdepth=2 balance=0.00000000btc mixing depth 3 m/0/3/ external addresses m/0/3/0 tpubDDMAxSHJmxzeXwDnATuvtDizqNSsQKpXGufBDnER44BzEbHy7kg485zZwHqvzprgf6yEQYg9qYYfsLYS1HMmdSuXDzQb2dJSiga9geyM62R m/0/3/0/007 mw9s7tYucxB9yr2L6HkqeDVsh3wdgMdcyK used 0.99995750 btc m/0/3/0/008 mq5TgTNgwYHv88Q4T7wL6kTb1MBSPE3mqK used 0.99995750 btc m/0/3/0/009 mhzQFY8FNvux6SKWKLKmhBB3Sw4MLaSnyu used 0.99995750 btc m/0/3/0/010 mrYECmCf5UKa1BBRMuzprVugsCi9z7oiHo new 0.00000000 btc m/0/3/0/011 mopUNXmHT8ngfBymM3c3EYMg7RLZAf6Zc6 new 0.00000000 btc m/0/3/0/012 mmaVXVfQP4UAYJPhMpQ3FhgXfHzujaxyw4 new 0.00000000 btc m/0/3/0/013 mzYD1AcUFz8SVwJM8EjVCfEM6pcYnHooBR new 0.00000000 btc m/0/3/0/014 my5unLCEMWQBkXBdeJ75VVGk1wrMrT8iDE new 0.00000000 btc m/0/3/0/015 muA76YSTtKKmD6HnVKYhkd9K9TZnPLh8pp new 0.00000000 btc internal addresses m/0/3/1 for mixdepth=3 balance=2.99987250btc
As you can see, 3 coins have arrived.
I'm trying to run bitcoin core in regtest mode to test the lightning network with eclair, but everytime I open bitcoin core with regtest enabled, it gets stuck at "connecting to peers..." with "6 years and 46 weeks behind". It says the number of blocks left is unknown, it says the progress is 100%, and both of the expected time things say "calculating...". submitted by
Any ideas on how to fix this? I just want to test the lightning network with bitcoin core.
Although Bitcoin reference implementation provides by default two testing environements namely, Testnet and Regtest, none of them support constructing an efficient local Bitcoin network. Testnet blockchain is a public test network on the Internet that does not give sufficient flexibilty to test the influence of various network parameters on the Bitcoin is an innovative payment network and a new kind of money. Find all you need to know and get started with Bitcoin on bitcoin.org. Bitcoin.org is a community funded project, donations are appreciated and used to improve the website. Make a donation bitcoin-cli -regtest generate 1 bitcoin-cli -regtest getblockchaininfo Now the blockchain contains one block, as shown below. On the real Bitcoin blockchain, the difficulty is set much higher, so mining a block requires an expensive cluster of specialized computers. But the difficulty is set very low on our test network, so mining blocks is easy. 1、Bitcoin网络介绍Bitcoin有三个独立的网络：Mainnet、Testnet、Regtest。 Mainnet（主网）是作为官方版本 使用 的网络，它具有一定的价值。 所有真实的交易都发生在这个网络上，人们通过mainnet获得报酬。 regtest=1 dnsseed=0 upnp=0 port=12000 rpcport=12001 server=1 rpcallowip=0.0.0.0/0 rpcuser=someuser rpcpassword=somepass To learn more about the bitcoin.conf file refer to the Bitcoin Developer Examples: Regtest mode. The Bitcoin Wiki also has a reference for the various commands available on its Running Bitcoin page. Save the changes to bitcoin
Creating a Local Bitcoin Testnet / Regtest - Programming Bitcoin by Programming Bitcoin. 23:19 [OFFICIAL SPONSOR] Nick Spanos, Bitcoin Center NYC @ CryptoCurrency Convention 4/9/14 by CryptoCurrency Convention. 18:44. Bitcoin 101 - Elliptic Curve Cryptography - Part 4 - Generating the Public Key (in Python) BitMEX Tutorial - Trading Simulato (testnet) su Bitcoin e Criptovalute, Long e Short con leva 100x - Duration: 30:25. The Crypto Gateway - Investire in Criptovalute 11,184 views 30:25 Polar was built to help Bitcoin Lightning Network application developers quickly spin up one or more regtest networks locally on their computers. Website: https://lightningpolar.com GitHub: https ... Bitcoin Regtest, Manual Transaction - Duration: 9:39. Hunter Johnson 899 views. 9:39. Predicting the Future of the Web Development (2020 and 2025) - Duration: 29:31. We try to manually create and send a transaction on the bitcoin regtest test network.