Git Product home page Git Product logo

tbtc-testnet-starter's Introduction

Developing with the BTC testnet can be quite slow:

  • difficulty can be very unpredictable.
  • sending/receiving transactions can take 10mins at least.
  • to make transactions, you need money from faucets.

This repo sets up:

  • a Bitcoin testnet using btcd and btcwallet.
  • a local ElectrumX server, forked to work with btcd.
  • pre-funded Bitcoin account for funding tBTC deposits.

Install.

git clone https://github.com/liamzebedee/tbtc-testnet-starter
cd tbtc-testnet-starter/
git submodule update --init --recursive

Usage.

btcd and ElectrumX are both built using Docker images. No additional software is needed.

# Start btcd, btcwallet.
$ ./scripts/run-btcd.sh

# Start ElectrumX.
$ ./scripts/run-electrumx.sh

The ElectrumX server will be running on ports 50001-50004.

Configuring tBTC

You must configure tbtc.js with the correct bitcoinNetwork and ElectrumX server.

const tbtc = await TBTC.withConfig({
    web3: web3,
    bitcoinNetwork: "simnet",    // (1)
    electrum: {
        testnetWS: {             // (2)
            server: "127.0.0.1",
            port: 50003,
            protocol: "ws"
        },
    }
})

You must also configure the tbtc-maintainer to connect to your local ElectrumX server. Edit your config.toml:

# Connection details of a Electrum Server.
[electrum]
    ServerHost  = "127.0.0.1"
    ServerPort  = "50002"
    Protocol    = "SSL" # TCP or SSL

Interacting with your bitcoin simnet.

$ docker exec -it btcd sh

# Send bitcoin from the "default" miner account.
/app $ btcctl -C ./btcctl.conf --wallet sendfrom default sb1qe2s2ag7n63jcrktewzfvfuawmgqscd5rdvet6y 0.001

# Mine a block.
/app $ btcctl -C ./btcctl.conf --wallet generate 1
[
  "7e4764ea96630a88c8cf2868393e72222b9f8f1a152f11c798ab717142ffbb98"
]

A brief explainer.

btcd is an alternative to the bitcoind software. It features a separate server, btcwallet, that hosts a wallet RPC interface. It comes with a tool called btcctl to send RPC calls to the btcd and btcwallet daemons.

We run a testnet instance of the bitcoin network called simnet. Simnet has its own address prefix, different from Bitcoin Testnet and Bitcoin Mainnet. simnet is a btcd-only feature (it's not part of bitcoind/bitcoin core).

ElectrumX doesn't support btcd out-of-the-box, and doesn't have a configuration for the simnet genesis. Hence, we use a forked version which is patched to support this.

tbtc-testnet-starter's People

Contributors

liamzebedee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

tbtc-testnet-starter's Issues

requestRedemption with P2PKH fails

deposit.requestRedemption('SZt6evokJ6FSJMgx43L1uosoQpesh7DBjE') fails with "Tx spends the wrong UTXO". However, it works with a bech32-formatted address, eg. "sb1qr64l8xglvwnvfqgnjjqtdz3v4fw45cq5v7l7dz".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.