Skip to content

Instantly share code, notes, and snippets.

@justinmoon
justinmoon / errors.js
Created April 11, 2020 20:21
hwi & bitcoin rpc errors
import { RPC_ERRORS, HWI_ERRORS } from "@app/constants"
const bitcoinRpcErrorCodeToConstant = {
"-32600": RPC_ERRORS.INVALID_REQUEST,
"-32601": RPC_ERRORS.METHOD_NOT_FOUND,
"-32602": RPC_ERRORS.INVALID_PARAMS,
"-32603": RPC_ERRORS.INTERNAL_ERROR,
"-32700": RPC_ERRORS.PARSE_ERROR,
"-1": RPC_ERRORS.MISC_ERROR,
"-3": RPC_ERRORS.TYPE_ERROR,
@justinmoon
justinmoon / gist:1c50eb24c5ef5874adab6fc38244409b
Created April 8, 2020 21:45
Bitcoin Core RPC Transactions (from slack discussion)
Remember how we've seen some weirdness in the output of listtransactions ?
If you make one transactions there will be multiple entries in our transaction list?
That's because each separate input / output gets a different entry in listtransactions
This is one transaction:
{
"involvesWatchonly": true,
"address": "bcrt1qg9xjv8raj57pynq39hmgswruectr6qzdmeppvtgnnrwjvs4z9hws42jalj",
@justinmoon
justinmoon / utils.js
Created April 3, 2020 03:08
bitcoin.conf javascript utils
// Just update for a single network. Maybe they don't want to enable their mainnet RPC, for instance ...
function updateBitcoinConfig(config, network) {
// Would be better if this required confirmation ...
delete config['global']['testnet']
delete config['global']['regtest']
config[network]['server'] = 1
config[network]['disablewallet'] = 0
return config
}
This file has been truncated, but you can view the full file.
$ cargo clean
$ cargo build -vv
Compiling cc v1.0.50
Compiling pkg-config v0.3.17
Running `CARGO_PKG_VERSION_MAJOR=1 CARGO_PKG_HOMEPAGE='https://github.com/alexcrichton/cc-rs' CARGO_PKG_AUTHORS='Alex Crichton <[email protected]>' CARGO_PKG_VERSION_MINOR=0 CARGO_PKG_VERSION_PATCH=50 CARGO_PKG_VERSION_PRE= CARGO_MANIFEST_DIR=/home/justin/.cargo/registry/src/github.com-1ecc6299db9ec823/cc-1.0.50 CARGO_PKG_VERSION=1.0.50 LD_LIBRARY_PATH='/home/justin/dev/runlibtor/target/debug/deps:/usr/lib' CARGO_PKG_NAME=cc CARGO=/usr/bin/cargo CARGO_PKG_DESCRIPTION='A build-time dependency for Cargo build scripts to assist in invoking the native
C compiler to compile native C code into a static archive to be linked into Rust
code.
' CARGO_PKG_REPOSITORY='https://github.com/alexcrichton/cc-rs' rustc --crate-name cc --edition=2018 /home/justin/.cargo/registry/src/github.com-1ecc6299db9ec823/cc-1.0.50/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,
$ cargo clean
$ cargo build -vv
Compiling cc v1.0.50
Compiling pkg-config v0.3.17
Running `CARGO_PKG_VERSION_MAJOR=1 CARGO_PKG_HOMEPAGE='https://github.com/alexcrichton/cc-rs' CARGO_PKG_AUTHORS='Alex Crichton <[email protected]>' CARGO_PKG_VERSION_MINOR=0 CARGO_PKG_VERSION_PATCH=50 CARGO_PKG_VERSION_PRE= CARGO_MANIFEST_DIR=/home/justin/.cargo/registry/src/github.com-1ecc6299db9ec823/cc-1.0.50 CARGO_PKG_VERSION=1.0.50 LD_LIBRARY_PATH='/home/justin/dev/runlibtor/target/debug/deps:/usr/lib' CARGO_PKG_NAME=cc CARGO=/usr/bin/cargo CARGO_PKG_DESCRIPTION='A build-time dependency for Cargo build scripts to assist in invoking the native
C compiler to compile native C code into a static archive to be linked into Rust
code.
' CARGO_PKG_REPOSITORY='https://github.com/alexcrichton/cc-rs' rustc --crate-name cc --edition=2018 /home/justin/.cargo/registry/src/github.com-1ecc6299db9ec823/cc-1.0.50/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,
$ cargo clean
$ cargo build -vv
Compiling cc v1.0.50
Compiling pkg-config v0.3.17
Running `CARGO_PKG_VERSION_MAJOR=1 CARGO_PKG_HOMEPAGE='https://github.com/alexcrichton/cc-rs' CARGO_PKG_AUTHORS='Alex Crichton <[email protected]>' CARGO_PKG_VERSION_MINOR=0 CARGO_PKG_VERSION_PATCH=50 CARGO_PKG_VERSION_PRE= CARGO_MANIFEST_DIR=/home/justin/.cargo/registry/src/github.com-1ecc6299db9ec823/cc-1.0.50 CARGO_PKG_VERSION=1.0.50 LD_LIBRARY_PATH='/home/justin/dev/runlibtor/target/debug/deps:/usr/lib' CARGO_PKG_NAME=cc CARGO=/usr/bin/cargo CARGO_PKG_DESCRIPTION='A build-time dependency for Cargo build scripts to assist in invoking the native
C compiler to compile native C code into a static archive to be linked into Rust
code.
' CARGO_PKG_REPOSITORY='https://github.com/alexcrichton/cc-rs' rustc --crate-name cc --edition=2018 /home/justin/.cargo/registry/src/github.com-1ecc6299db9ec823/cc-1.0.50/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,
const spawnCkcc = require('./src/utils/ckcc.js')
const spawnHwi = require('./src/utils/hwi.js')
spawnHwi(['--fingerprint=f25d9737', 'getxpub', "m/0"])
.then(r => console.log('hwi success', r))
.catch(e => console.log('hwi error', e))
spawnCkcc(['xpub', "m/0"])
.then(r => console.log('ckcc success', r))
.catch(e => console.log('ckcc error', e))
spawnHwi(['--fingerprint=f25d9737', 'getxpub', "m/0"])
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
```
$ npm run test
[email protected] test /home/justin/dev/junctionwallet/web
mocha --require ./test_init.js src/**/*.test.js
```
$ tree
.
├── index.json
├── opam
│   ├── astring.0.8.3
│   │   └── opam
│   ├── atd.2.0.0
│   │   └── opam
│   ├── atdgen.2.0.0