keep-network / local-setup

Allow to easily set up tBTC and Keep locally for development and test purposes.
MIT License
8 stars 16 forks source link

Add cli helper to send and receive btc from local btc node #25

Closed ironng closed 3 years ago

ironng commented 4 years ago

This creates a small package that exposes the sendToAddress and getNewAddress from bitcoind-rpc to the command line so we can interact with the local bitcoin node. It automatically creates an BitcoinRPC instance using the same config from the e2e tests. In fact, it just wraps logic taken originally from the e2e test script. :)

To use, simply run npm install -g <path-to-this-package>. (Requires node version > 12.0)

Send:

$ bitcoind-wallet sendToAddress bcrt1q55zfnwqzjs76xknj5rhy5q5n85s6ctz2lvn03u 0.01

Get address:

$ bitcoind-wallet getNewAddress

Alternatively, we can just use the package bitcoin-cli, which exposes all methods from bitcoind-rpc, and pass in all the config options via flags. We can update the readme with whatever one we choose.

beaurancourt commented 3 years ago

From experimentation, I cd'd into this repo and then ran:

npm install -g ./bitcoind-wallet

notably,

npm install -g bitcoind-wallet

did not work!

Shadowfiend commented 3 years ago

Marking this ready to merge now. @beaushinkle did we have to change/add anything for you to use this successfully? If not, we can merge as-is. If yes, feel free to take this PR over.

beaurancourt commented 3 years ago

yeah, we had to add a flag somewhere, but i don't remember where :scream:

beaurancourt commented 3 years ago
beaushinkle@Beaus-MBP ~/local (bitcoind-cli-helper)> npm install -g ./bitcoind-wallet

added 1 package, and audited 3 packages in 351ms

found 0 vulnerabilities
beaushinkle@Beaus-MBP ~/local (bitcoind-cli-helper)> bitcoind-wallet getNewAddress
(node:81881) ExperimentalWarning: Importing JSON modules is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
bcrt1qqc3gj54q5rdd9rl0zm9qxv9rj9vtzd0m4hgq9s

should be good to go!