Giter VIP home page Giter VIP logo

nigiri's Introduction

🍣 Nigiri Bitcoin

Nigiri provides a command line interface that manages a selection of docker-compose batteries included to have ready-to-use bitcoin regtest development environment, with a bitcoin node, electrum explorer both backend and frontend user interface.

It offers a JSON HTTP proxy passtrough that adds to the explorer handy endpoints like /faucet and automatic block generation when calling the /tx pushing a transaction.

You can have Lightning with --ln flag and/or Elements with the --liquid flag.

No time to make a Nigiri yourself?

Pre-built binary

  • Download and install nigiri command line interface
$ curl https://getnigiri.vulpem.com | bash

This will also install several configurable files, such as bitcoin.conf and elements.conf, that can be edited. These can be found browsing the following directory:

POSIX (Linux/BSD): ~/.nigiri

macOS: $HOME/Library/Application\ Support/Nigiri

Windows: %LOCALAPPDATA%\Nigiri

Plan 9: $home/nigiri

  • Lauch Docker daemon (Mac OSX)
$ open -a Docker

You may want to Manage Docker as a non-root user

  • Close and reopen your terminal, then start Bitcoin and Liquid
$ nigiri start --liquid

That's it.

Go to http://localhost:5000 for quickly inspect the Bitcoin blockchain or http://localhost:5001 for Liquid.

Note for users of macOS Monterey an onward

Show more... When trying to start Nigiri, you might get an error similar to the following:
Error response from daemon: Ports are not available: listen tcp 0.0.0.0:5000: bind: address already in use 
exit status 1

This is due to AirPlay Receiver using port 5000, conflicting with Esplora trying to run using the very same port.

There are two ways to deal with this issue:

  1. Uncheck AirPlay Receiver in System Preferences β†’ Sharing β†’ AirPlay Receiver
  2. Change Esplora’s port to something other than 5000. This can be done by changing it in docker-compose.yml found in your data directory. If you previously tried starting Nigiri getting an error – you might have to run nigiri stop --delete before restarting it.

Tasting

At the moment bitcoind, elements and electrs are started on regtest network.

Start nigiri

$ nigiri start
  • Use the --liquid flag to let you do experiments with the Liquid sidechain. A liquid daemon and a block explorer are also started when passing this flag.

  • Use the --ln flag to start a Core Lightning node, a LND node and a Tap daemon.

Stop nigiri

$ nigiri stop

Use the --delete flag to not just stop Docker containers but also to remove them and delete the config file and any new data written in volumes.

Generate and send bitcoin to given address

# Bitcoin
$ nigiri faucet <bitcoin_address>
## Fund the Core Lightning node
$ nigiri faucet cln 0.01

## Fund the LND node
$ nigiri faucet lnd 0.01

# Elements
$ nigiri faucet --liquid <liquid_address>

Send Liquid asset to given address

$ nigiri faucet --liquid <liquid_address> <amt> <liquid_asset>

Liquid only Issue and send a given quantity of an asset

$ nigiri mint <liquid_address> 1000 VulpemToken VLP

Broadcast a raw transaction and automatically generate a block

# Bitcoin
$ nigiri push <hex>

# Elements
$ nigiri push --liquid <hex>

Check the logs of Bitcoin services

# Bitcoind
$ nigiri logs bitcoin
# Electrs
$ nigiri logs electrs
# Chopsticks
$ nigiri logs chopsticks

Check the logs of Liquid services

# Elementsd
$ nigiri logs liquid
# Electrs Liquid
$ nigiri logs electrs-liquid
# Chopsticks Liquid
$ nigiri logs chopsticks-liquid

Check the logs of Lightning services

# Core Lightning
$ nigiri logs cln
# LND
$ nigiri logs lnd

Use the Bitcoin CLI inside the box

$ nigiri rpc getnewaddress "" "bech32"
bcrt1qsl4j5je4gu3ecjle8lckl3u8yywh8rff6xxk2r

Use the Elements CLI inside the box

$ nigiri rpc --liquid getnewaddress "" "bech32"
el1qqwwx9gyrcrjrhgnrnjq9dq9t4hykmr6ela46ej63dnkdkcg8veadrvg5p0xg0zd6j3aug74cv9m4cf4jslwdqnha2w2nsg9x3

Use the Core Lightning & LND CLIs inside the box

# Core Lightning
$ nigiri cln listpeers
# LND
$ nigiri lnd listpeers
# Tap (Taro)
$ nigiri tap assets list

Connect Core Lightning to LND

$ nigiri cln connect `nigiri lnd getinfo | jq -r .identity_pubkey`@lnd:9735

Open a channel between cln and lnd

$ nigiri lnd openchannel --node_key=`nigiri cln getinfo | jq -r .id` --local_amt=100000

Run in headless mode (without Esplora)

If you are looking to spin-up Nigiri in Travis or Github Action you can use the --ci flag.

$ nigiri start --ci [--liquid] [--ln]

Update the docker images

$ nigiri update

Nigiri uses the default directory ~/.nigiri to store configuration files and docker-compose files. To set a custom directory use the --datadir flag.

Run the help command to see the full list of available flags.

Make from scratch

Utensils

Ingredients

Directions

Preparation Time: 5 min Cooking Difficulty: Easy
  • Clone the repo:
$ git clone https://github.com/vulpemventures/nigiri.git
  • Enter project directory and install dependencies:
$ make install
  • Build binary
$ make build

Done! You should be able to find the binary in the local ./build folder. Give it permission to execute and move/rename into your PATH.

  • Clean

Remeber to always clean Nigiri before running install to upgrade to a new version.

$ make clean

Nutrition Facts

Chopsticks service exposes on port 3000 (and on 3001 if started with --liquid flag) all Esplora's available endpoints and extends them with the following:

Bitcoin & Liquid

  • POST /faucet which expects a body { "address": <receiving_address> }
  • POST /tx has been extended to automatically mine a block when is called.

Liquid only

  • POST /mint which expects a body {"address": "ert1q90dz89u8eudeswzynl3p2jke564ejc2cnfcwuq", "quantity": 1000, "name":"VULPEM", "ticker":"VLP"}
  • POST /registry to get extra info about one or more assets like name and ticker which expects a body with an array of assets {"assets": ["2dcf5a8834645654911964ec3602426fd3b9b4017554d3f9c19403e7fc1411d3"]}

Footnotes

If you really do love Sathoshi's favourite dish like us at Vulpem Ventures, check the real recipe out and enjoy your own, delicious, hand made nigiri sushi.

nigiri's People

Contributors

aferreira44 avatar altafan avatar andrei-21 avatar danielgranhao avatar dependabot[bot] avatar francismars avatar louisinger avatar notmandatory avatar oliveroffing avatar schjonhaug avatar tiero avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nigiri's Issues

Add nigiri log command

It can be something like

nigiri <chain> <service> log

or defaulting to chain bitcoin and add flag --liquid

nigiri log --liquid --service=electrs (default --liquid=false and --service=node)

simple CLI that wraps current bash scripts

Would be nice instead of cloning manually and launch scripts, to create simple command line interface that wraps current bash scripts. Since the repo will be public, it's ok to download the current repo

nigiri-cli start --network regtest --chain `all|bitcoin|liquid`
nigiri-cli stop 
nigiri-cli clean  

create will be done automatically by cli if not already done, as well some cleaning on stop could be done (not destroying the image ofc)

Integration tests and CI

Add a docker based CI pipeline to build the cli, pull the images and test the command against to it.

test the basic commands for all interfaces of services (REST, chopstick, electrum rpc, bitcoin rpc, liquid rpc)

Add Liquid.Coach

It would be very helpful for Liquid Developers to have a service like Liquid.Coach spun up in the box.

This means:

  1. Dockerize the orginal web application
  2. Create a travis pipeline that pushes to Docker Hub (look to the nigiri chopsticks one)
  3. Add it to the docker compose of Liquid
  4. expose a free port for it.

Add txindex to elements.conf

After upgrading the version of the elements node I'm not able anymore to use cli commands like decoderawtransaction that returns the error No such mempool transaction. Use -txindex to enable blockchain transaction queries. Use gettransaction for wallet transactions.

Add Lightning Network

The ideal high-level flow should be the same as the liquid one, passing the optional flag -ln or --lightning

Being the network regtest where we are focusing on, we need at least two different wallets in order to open channels and use for local development. We can use both c-lightning and lnd so in this way we can cross-test the two main implementations.

Drop link directive in compose

depends_on directive is enough to make each container reachable in the same local network, and also link is deprecated.

What to do?
Remove the link directive in each service in the docker-compose-regtest.yml and docker-compose-regtest-liquid.yml

Support for testnet and mainnet

Ideally there will be needed walletdisabled in both conf. A nice to have for nigiri-chopsticks is a tor hidden service, along with an API-KEY authentication at the proxy level.

Use Nigiri in Travis or other CI pipelines

This would be a nice to be served as nigiri start --ci --liquid in order to pull an optimized version of nigiri for continuous integration pipelines like Travis. Eg. without the esplora frontends

nigiri create - resources/docker-compose-regtest.yml is not created

After installing and building with the last master I have on create command:

➜  nigiri git:(master) build/nigiri-darwin-amd64 create
ERROR: .FileNotFoundError: [Errno 2] No such file or directory: '/Users/tiero/.nigiri/resources/docker-compose-regtest.yml'
FATA[0000] An error occured while composing Docker environment  error="exit status 1"

If I open '/Users/tiero/.nigiri/ I found ONLY a nigiri.config.json and not a resources folder. How someone is supposed to develop without having to download the binaries to get conf files?
I think yamls and .conf should be present both as a source in the git commit and in the binaries.

electrs crashes

electrs.tar.gz
The archive contains the electrs w/ liquid build of the last new-index branch of Blockstream/electrs.
This version creashes when mining a block giving me the error:

Config { log: StdErrLog { verbosity: Trace, quiet: false, timestamp: Off, modules: [], writer: "stderr", color_choice: Auto }, network_type: LiquidRegtest, db_path: "./db/liquidregtest", daemon_dir: "/config/liquidregtest", daemon_rpc_addr: V4(10.10.0.11:18884), cookie: Some("admin1:123"), electrum_rpc_addr: V4(127.0.0.1:51401), http_addr: V4(0.0.0.0:3002), monitoring_addr: V4(127.0.0.1:44224), jsonrpc_import: false, index_batch_size: 100, bulk_index_threads: 2, tx_cache_size: 10000, prevout_enabled: true, cors: None, precache_scripts: None, parent_network: Bitcoin, parent_genesis_hash: "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f" }
DEBUG - Server listening on 127.0.0.1:44224
WARN - reconnecting to bitcoind: {"code":-28,"message":"Verifying wallet..."}
DEBUG - Running accept thread
WARN - reconnecting to bitcoind: {"code":-28,"message":"Loading wallet..."}
INFO - NetworkInfo { version: 3140123, subversion: "/Liquid:3.14.1.23/" }
INFO - BlockchainInfo { chain: "liquidregtest", blocks: 0, headers: 0, bestblockhash: "1dfe15bb36db2806449fd64f601a8b04fd00af800bfe6be5daf2d8ac9bf0bf09", pruned: false, verificationprogress: 0.0, initialblockdownload: Some(true) }
DEBUG - opening DB at "./db/liquidregtest/newindex/txstore"
DEBUG - 0 blocks were added
DEBUG - opening DB at "./db/liquidregtest/newindex/history"
DEBUG - 0 blocks were indexed
DEBUG - 0 headers were loaded
DEBUG - opening DB at "./db/liquidregtest/newindex/cache"
DEBUG - downloading all block headers up to 846821dad2619b851afe9fdfbc314999853a2f1bc4a41073b7def42e02028902
TRACE - downloading 2 block headers
INFO - best=846821dad2619b851afe9fdfbc314999853a2f1bc4a41073b7def42e02028902 height=1 @ 2019-04-08T17:39:48Z (2 left to process)
DEBUG - adding transactions from 2 blocks using BlkFiles
DEBUG - listing block files at "/config/liquidregtest/blocks/blk*.dat"
TRACE - reading "/config/liquidregtest/blocks/blk00000.dat"
TRACE - parsing 16777216 bytes
TRACE - fetched 2 blocks
DEBUG - writing 114 rows to RocksDB { path: "./db/liquidregtest/newindex/txstore" }, flush=Disable
DEBUG - starting full compaction on RocksDB { path: "./db/liquidregtest/newindex/txstore" }
DEBUG - finished full compaction on RocksDB { path: "./db/liquidregtest/newindex/txstore" }
DEBUG - indexing history from 2 blocks using BlkFiles
DEBUG - listing block files at "/config/liquidregtest/blocks/blk*.dat"
TRACE - reading "/config/liquidregtest/blocks/blk00000.dat"
TRACE - parsing 16777216 bytes
TRACE - fetched 2 blocks
thread 'lookup-txo-12' panicked at 'missing txo [elements]50cdc410c9d0d61eeacc531f52d2c70af741da33af127c364e52ac1ee7c030a5:0 in DB { db: RocksDB { path: "./db/liquidregtest/newindex/txstore" } }', src/new_index/schema.rs:781:29

I can reproduce this error by editing the existing docker-compose-regtest-liquid.yml as:

version: '3'
services:
  bitcoin:
    image: vulpemventures/bitcoin:latest
    networks:
      local:
        ipv4_address: 10.10.0.10
    volumes:
      - ./volumes/liquidregtest/config/:/config
    ports:
      - 19001:19001
  liquid:
    image: vulpemventures/liquid:latest
    networks:
      local:
        ipv4_address: 10.10.0.11
    volumes:
      - ./volumes/liquidregtest/liquid-config/:/config
    ports:
      - 18884:18884
  # electrs:
  #   image: vulpemventures/electrs:latest
  #   entrypoint:
  #     - /build/electrs
  #   command:
  #     - -vvvv
  #     - --network
  #     - regtest
  #     - --daemon-dir
  #     - /config
  #     - --daemon-rpc-addr
  #     - 10.10.0.10:19001
  #     - --cookie
  #     - admin1:123
  #     - --http-addr
  #     - 0.0.0.0:3002
  #   networks:
  #     local:
  #       ipv4_address: 10.10.0.12
  #   ports:
  #     - 3002:3002
  #   volumes:
  #     - ./volumes/liquidregtest/config/:/config
  electrs-liquid:
    # instead of using
    # image: vulpemventures/electrs-liquid:latest
    build:
      context: electrs
      dockerfile: Dockerfile
    networks:
      local:
        ipv4_address: 10.10.0.13
    entrypoint:
      - /build/electrs
    command:
      - -vvvv
      - --network
      - liquidregtest
      - --daemon-dir
      - /config
      - --daemon-rpc-addr
      - 10.10.0.11:18884
      - --cookie
      - admin1:123
      - --http-addr
      - 0.0.0.0:3002
    volumes:
      - ./volumes/liquidregtest/liquid-config/:/config
    ports:
      - 3002:3002
  # chopsticks:
  # 	build:
  # 		context: chopsticks/
  #		dockerfile: Dockerfile
  # 	ports:
  # 		- 3000:3000
  # 	networks:
  # 		local:
  # 			ipv4_address: 10.10.0.13

networks:
  local:
    driver: bridge
    ipam:
      config:
        - subnet: 10.10.0.0/24

Create a directory electrs/ in the same folder where you have the YAML (default ~/.nigiri) and place the binary above with this minimal Dockerfile:

FROM ubuntu:18.04

WORKDIR /build

ADD electrs .

EXPOSE 3002

ENTRYPOINT ["/build/electrs"]

Travis yaml

Create an additional pipeline using free Travis service

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.