A hacker-friendly, command line BCH and SLP wallet built with bch-js
npm install slp-cli-wallet_Warning: This is an experimental 'hacker-friendly' wallet. It's intended for use by software developers. It has been tested only for the most common use-cases. It has been known to burn SLP tokens. Do not use this wallet for tokens with value._
This is an npm library and Bitcoin Cash (BCH) wallet that runs on the command
line. Add this library to your app to instantly give it the ability to transact
on the BCH network! New to Bitcoin Cash? Find educational resources on the FullStack.cash Documenation page.
This project has the following goals:
- Create a code base for a wallet that is easily forkable and extensible by JavaScript developers.
- Provide a high-level abstraction to make it easy for new developers to add BCH and SLP wallet functionality into their apps.
If you want a wallet with a graphical user interface, check out wallet.FullStack.cash. For a front-end friendly package, check out minimal-slp-wallet-web. Bitcoin Cash functionality is implemented in all wallets with bch-js, provided by FullStack.cash. The command line interface for this project is built with oclif.
Also, be sure to check out the design decisions and trade-offs that went into the
creation of this project in the docs directory
* slp-cli-wallet
* NPM Usage
* Install Dev Environment
* Command Line Usage
* Commands
The npm library can be included
in your own app to instantly give it the ability to send and receive BCH transactions, including SLP tokens.
Here is an example of how to include it in your own app. This example will generate
a new HD wallet.
``javascript
// Instantiate the Create Wallet class from this library.
const CreateWallet = require('slp-cli-wallet/src/commands/create-wallet')
const createWallet = new CreateWallet()
const walletFile = './wallet.json'
async function makeNewWallet() {
const wallet = await createWallet.createWallet(walletFile)
console.log(wallet: ${JSON.stringify(wallet, null, 2)})`
}
makeNewWallet()
This app is tested on the following versions for npm and node.js:
- npm: v7.12.1
- node.js: v14.16.1
While this npm library can be used globally, the intended audience is developers
familiar with the usage of npm and git. Here is how to set up your own
developer environment:
- Clone this repo with git clone.npm install
- Install npm dependencies with ./bin/run help
- Execute the commands like this:
Running the wallet this way, you can edit the behavior of the wallet
by making changes to the code in the src/commands directory.
`sh-session`
$ npm install -g slp-cli-wallet
$ slp-cli-wallet COMMAND
running command...
$ slp-cli-wallet (-v|--version|version)
slp-cli-wallet/3.2.1 linux-x64 node-v14.15.0
$ slp-cli-wallet --help [COMMAND]
USAGE
$ slp-cli-wallet COMMAND
...
* slp-cli-wallet burn-tokens
* slp-cli-wallet create-wallet
* slp-cli-wallet derivation
* slp-cli-wallet get-address
* slp-cli-wallet get-key
* [slp-cli-wallet help [COMMAND]](#slp-cli-wallet-help-command)slp-cli-wallet list-wallets
* slp-cli-wallet nft-create-child
* slp-cli-wallet nft-create-group
* slp-cli-wallet nft-list-addr
* slp-cli-wallet nft-list-tokens
* slp-cli-wallet nft-remove-child
* slp-cli-wallet remove-wallet
* slp-cli-wallet scan-funds
* slp-cli-wallet send
* slp-cli-wallet send-all
* slp-cli-wallet send-tokens
* slp-cli-wallet sign-message
* slp-cli-wallet slp-avax-bridge
* slp-cli-wallet sweep
* slp-cli-wallet update-balances
*
Burn SLP tokens.
`
USAGE
$ slp-cli-wallet burn-tokens
OPTIONS
-n, --name=name Name of wallet
-q, --qty=qty
-t, --tokenId=tokenId Token ID
`
_See code: src/commands/burn-tokens.js_
Generate a new HD Wallet.
`
USAGE
$ slp-cli-wallet create-wallet
OPTIONS
-d, --description=description Description of the wallet
-n, --name=name Name of wallet
-t, --testnet Create a testnet wallet
`
_See code: src/commands/create-wallet.js_
Display or set the derivation path used by the wallet.
`
USAGE
$ slp-cli-wallet derivation
OPTIONS
-n, --name=name name to print
-s, --save=save save a new derivation path
DESCRIPTION
This command is used to display the derivation path used by the wallet. The -s
flag can be used to save a new derivation path.
Common derivation paths used:
145 - BIP44 standard path for Bitcoin Cash
245 - BIP44 standard path for SLP tokens
0 - Used by common software like the Bitcoin.com wallet and Honest.cash
Wallets use the 245 derivation path by default.
`
_See code: src/commands/derivation.js_
Generate a new address to recieve BCH.
`
USAGE
$ slp-cli-wallet get-address
OPTIONS
-n, --name=name Name of wallet
-s, --slp Generate a simpledger: token address
-t, --testnet Create a testnet wallet
`
_See code: src/commands/get-address.js_
Generate a new private/public key pair.
`
USAGE
$ slp-cli-wallet get-key
OPTIONS
-n, --name=name Name of wallet
`
_See code: src/commands/get-key.js_
display help for slp-cli-wallet
`
USAGE
$ slp-cli-wallet help [COMMAND]
ARGUMENTS
COMMAND command to show help for
OPTIONS
--all see all commands in CLI
`
_See code: @oclif/plugin-help_
List existing wallets.
``
USAGE
$ slp-cli-wallet list-wallets
_See code: src/commands/list-wallets.js_
Create NFT child
`
USAGE
$ slp-cli-wallet nft-create-child
OPTIONS
-c, --child=child Name of the child
-f, --funder=funder Fee funder address index in the wallet
-g, --groupId=groupId NFT Group ID
-h, --hash=hash Document hash of the group
-i, --index=index Address index in the wallet
-n, --name=name Name of wallet
-r, --receiver=receiver Address to send the token
-t, --ticker=ticker Ticker of the child
-u, --url=url Document URL of the group
DESCRIPTION
...
Will create NFT child token in a specified NFT group (groupId parameter)
`
_See code: src/commands/nft-create-child.js_
Create NFT Group
`
USAGE
$ slp-cli-wallet nft-create-group
OPTIONS
-a, --amount=amount
-f, --funder=funder Fee funder address index in the wallet
-g, --group=group Name of the group
-h, --hash=hash Document hash of the group
-i, --index=index Address index in the wallet
-n, --name=name Name of wallet
-t, --ticker=ticker Ticker of the group
-u, --url=url Document URL of the group
DESCRIPTION
...
Will create NFT group with specified name, ticker and amount
`
_See code: src/commands/nft-create-group.js_
List addresses inside the wallet
`
USAGE
$ slp-cli-wallet nft-list-addr
OPTIONS
-n, --name=name Name of wallet
DESCRIPTION
...
Will return a list of available addresses
`
_See code: src/commands/nft-list-addr.js_
List NFT tokens in a wallet address
`
USAGE
$ slp-cli-wallet nft-list-tokens
OPTIONS
-g, --groups List only NFT groups
-i, --index=index Address index in the wallet
-n, --name=name Name of wallet
DESCRIPTION
...
Will return a JSON formated list of available NFT tokens
`
_See code: src/commands/nft-list-tokens.js_
Remove NFT child token
`
USAGE
$ slp-cli-wallet nft-remove-child
OPTIONS
-f, --funder=funder Fee funder address index in the wallet
-i, --index=index Address index in the wallet
-n, --name=name Name of wallet
-t, --tokenId=tokenId NFT child tokenId
DESCRIPTION
...
Will remove NFT child token (type = 65) with specified tokenId
`
_See code: src/commands/nft-remove-child.js_
Remove an existing wallet.
`
USAGE
$ slp-cli-wallet remove-wallet
OPTIONS
-n, --name=name Name of wallet
`
_See code: src/commands/remove-wallet.js_
Scans first 20 addresses of each derivation path for
`
USAGE
$ slp-cli-wallet scan-funds
OPTIONS
-m, --mnemonic=mnemonic mnemonic phrase to generate addresses, wrapped in quotes
DESCRIPTION
history and balance of the given mnemonic. If any of them had a history, scans
the next 20, until it reaches a batch of 20 addresses with no history. The -m
flag is used to pass it a mnemonic phrase.
Derivation pathes used:
145 - BIP44 standard path for Bitcoin Cash
245 - BIP44 standard path for SLP tokens
0 - Used by common software like the Bitcoin.com wallet and Honest.cash
`
_See code: src/commands/scan-funds.js_
Send an amount of BCH
`
USAGE
$ slp-cli-wallet send
OPTIONS
-a, --sendAddr=sendAddr Cash address to send to
-b, --bch=bch Quantity in BCH
-n, --name=name Name of wallet
`
_See code: src/commands/send.js_
Send all BCH in a wallet to another address. Degrades Privacy
`
USAGE
$ slp-cli-wallet send-all
OPTIONS
-a, --sendAddr=sendAddr Cash address to send to
-i, --ignoreTokens Ignore and burn tokens
-n, --name=name Name of wallet
DESCRIPTION
Send all BCH in a wallet to another address.
This method has a negative impact on privacy by linking all addresses in a
wallet. If privacy of a concern, CoinJoin should be used.
This is a good article describing the privacy concerns:
https://bit.ly/2TnhdVc
`
_See code: src/commands/send-all.js_
Send SLP tokens.
`
USAGE
$ slp-cli-wallet send-tokens
OPTIONS
-a, --sendAddr=sendAddr Cash or SimpleLedger address to send to
-n, --name=name Name of wallet
-q, --qty=qty
-t, --tokenId=tokenId Token ID
`
_See code: src/commands/send-tokens.js_
Sign message
`
USAGE
$ slp-cli-wallet sign-message
OPTIONS
-i, --sendAddrIndex=sendAddrIndex Address index
-m, --message=message Message to sign. (Wrap in quotes)
-n, --name=name Name of wallet
`
_See code: src/commands/sign-message.js_
Send SLP tokens.
`
USAGE
$ slp-cli-wallet slp-avax-bridge
OPTIONS
-a, --sendAddr=sendAddr [default: bitcoincash:qrmjjjhz0a7dhp46ymw36l9zd0wcfryahq3s4989yj] Cash or SimpleLedger bridge
address
-n, --name=name Name of wallet
-q, --qty=qty
-t, --tokenId=tokenId [default: c43eb59134473addee345df4172f4432bd09a8f087ba683462f0d66f8d221213] Token ID
-x, --avaxAddr=avaxAddr Avalanche address to send tokens to from the bridge
`
_See code: src/commands/slp-avax-bridge.js_
Sweep a private key
`
USAGE
$ slp-cli-wallet sweep
OPTIONS
-a, --address=address Address to sweep funds to.
-b, --balanceOnly Balance only, no claim.
-i, --tokenId=tokenId The token ID to sweep when there are multiple tokens
-t, --testnet Testnet
-w, --wif=wif WIF private key
DESCRIPTION
...
Sweeps a private key in WIF format.
Supports SLP token sweeping, but only one token class at a time. It will throw
an error if a WIF contains more than one class of token.
`
_See code: src/commands/sweep.js_
Poll the network and update the balances of the wallet.
`
USAGE
$ slp-cli-wallet update-balances
OPTIONS
-i, --ignoreTokens Ignore and burn tokens
-n, --name=name Name of wallet
``
_See code: src/commands/update-balances.js_