parent
406a3303bb
commit
76c5ba8000
@ -0,0 +1,186 @@
|
||||
[[appdx_bx]]
|
||||
[appendix]
|
||||
|
||||
== Available Bitcoin Explorer Commands
|
||||
|
||||
((("Bitcoin Explorer commands","commands in", id="ix_appdx-bx-asciidoc0", range="startofrange")))
|
||||
|
||||
----
|
||||
Usage: bx COMMAND [--help]
|
||||
|
||||
Info: The bx commands are:
|
||||
|
||||
address-decode
|
||||
address-embed
|
||||
address-encode
|
||||
address-validate
|
||||
base16-decode
|
||||
base16-encode
|
||||
base58-decode
|
||||
base58-encode
|
||||
base58check-decode
|
||||
base58check-encode
|
||||
base64-decode
|
||||
base64-encode
|
||||
bitcoin160
|
||||
bitcoin256
|
||||
btc-to-satoshi
|
||||
ec-add
|
||||
ec-add-secrets
|
||||
ec-multiply
|
||||
ec-multiply-secrets
|
||||
ec-new
|
||||
ec-to-address
|
||||
ec-to-public
|
||||
ec-to-wif
|
||||
fetch-balance
|
||||
fetch-header
|
||||
fetch-height
|
||||
fetch-history
|
||||
fetch-stealth
|
||||
fetch-tx
|
||||
fetch-tx-index
|
||||
hd-new
|
||||
hd-private
|
||||
hd-public
|
||||
hd-to-address
|
||||
hd-to-ec
|
||||
hd-to-public
|
||||
hd-to-wif
|
||||
help
|
||||
input-set
|
||||
input-sign
|
||||
input-validate
|
||||
message-sign
|
||||
message-validate
|
||||
mnemonic-decode
|
||||
mnemonic-encode
|
||||
ripemd160
|
||||
satoshi-to-btc
|
||||
script-decode
|
||||
script-encode
|
||||
script-to-address
|
||||
seed
|
||||
send-tx
|
||||
send-tx-node
|
||||
send-tx-p2p
|
||||
settings
|
||||
sha160
|
||||
sha256
|
||||
sha512
|
||||
stealth-decode
|
||||
stealth-encode
|
||||
stealth-public
|
||||
stealth-secret
|
||||
stealth-shared
|
||||
tx-decode
|
||||
tx-encode
|
||||
uri-decode
|
||||
uri-encode
|
||||
validate-tx
|
||||
watch-address
|
||||
wif-to-ec
|
||||
wif-to-public
|
||||
wrap-decode
|
||||
wrap-encode
|
||||
|
||||
Bitcoin Explorer home page:
|
||||
|
||||
https://github.com/libbitcoin/libbitcoin-explorer
|
||||
|
||||
Bitcoin Explorer user documentation:
|
||||
|
||||
https://github.com/libbitcoin/libbitcoin-explorer/wiki
|
||||
|
||||
----
|
||||
|
||||
Next, we look at some examples of using Bitcoin Explorer commands to experiment with keys and addresses.
|
||||
|
||||
Generate a random "seed" value using the((("Bitcoin Explorer","seed command")))((("seed command (bx)"))) +seed+ command, which uses the operating system's random number generator. Pass the seed to the((("Bitcoin Explorer","ec-new command")))((("ec-new command (bx)"))) +ec-new+ command to generate a new private key. We save the standard output into the file _private_key_:
|
||||
|
||||
----
|
||||
$ bx seed | bx ec-new > private_key
|
||||
$ cat private_key
|
||||
73096ed11ab9f1db6135857958ece7d73ea7c30862145bcc4bbc7649075de474
|
||||
----
|
||||
|
||||
Now, generate the public key from that private key using the((("Bitcoin Explorer","ec-to-public command")))((("ec-to-public command (bx)"))) +ec-to-public+ command. We pass the _private_key_ file into the standard input and save the standard output of the command into a new file _public_key_:
|
||||
|
||||
----
|
||||
$ bx ec-to-public < private_key > public_key
|
||||
$ cat public_key
|
||||
02fca46a6006a62dfdd2dbb2149359d0d97a04f430f12a7626dd409256c12be500
|
||||
----
|
||||
|
||||
We can reformat the +public_key+ as an address using the((("Bitcoin Explorer","ec-to-address command")))((("ec-to-address command (bx)"))) +ec-to-address+ command. We pass the _public_key_ into standard input:
|
||||
|
||||
----
|
||||
$ bx ec-to-address < public_key
|
||||
17re1S4Q8ZHyCP8Kw7xQad1Lr6XUzWUnkG
|
||||
----
|
||||
|
||||
Keys generated in this manner produce a type-0 nondeterministic wallet. That means that each key is generated from an independent seed. Bitcoin Explorer commands can also generate keys deterministically, in accordance with BIP0032. In this case a "master" key is created from a seed and then extended deterministically to produce a tree of subkeys, resulting in a type-2 deterministic wallet.
|
||||
|
||||
First, we we use the((("Bitcoin Explorer","seed command")))((("seed command (bx)"))) +seed+ and((("Bitcoin Explorer","hd-new command")))((("hd-new command (bx)"))) +hd-new+ commands to generate a master key that will be used as the basis to derive a hierarchy of keys.
|
||||
|
||||
----
|
||||
$ bx seed > seed
|
||||
$ cat seed
|
||||
eb68ee9f3df6bd4441a9feadec179ff1
|
||||
|
||||
$ bx hd-new < seed > master
|
||||
$ cat master
|
||||
xprv9s21ZrQH143K2BEhMYpNQoUvAgiEjArAVaZaCTgsaGe6LsAnwubeiTcDzd23mAoyizm9cApe51gNfLMkBqkYoWWMCRwzfuJk8RwF1SVEpAQ
|
||||
----
|
||||
|
||||
We now use the((("Bitcoin Explorer","hd-private command")))((("hd-private command (bx)"))) +hd-private+ command to generate a hardened "account" key and a sequence of two private keys within the account.
|
||||
|
||||
----
|
||||
$ bx hd-private --hard < master > account
|
||||
$ cat account
|
||||
xprv9vkDLt81dTKjwHB8fsVB5QK8cGnzveChzSrtCfvu3aMWvQaThp59ueufuyQ8Qi3qpjk4aKsbmbfxwcgS8PYbgoR2NWHeLyvg4DhoEE68A1n
|
||||
|
||||
$ bx hd-private --index 0 < account
|
||||
xprv9xHfb6w1vX9xgZyPNXVgAhPxSsEkeRcPHEUV5iJcVEsuUEACvR3NRY3fpGhcnBiDbvG4LgndirDsia1e9F3DWPkX7Tp1V1u97HKG1FJwUpU
|
||||
|
||||
$ bx hd-private --index 1 < account
|
||||
xprv9xHfb6w1vX9xjc8XbN4GN86jzNAZ6xHEqYxzbLB4fzHFd6VqCLPGRZFsdjsuMVERadbgDbziCRJru9n6tzEWrASVpEdrZrFidt1RDfn4yA3
|
||||
----
|
||||
|
||||
Next we use the((("Bitcoin Explorer","hd-public command")))((("hd-public command (bx)"))) +hd-public+ command to generate the corresponding sequence of two public keys.
|
||||
|
||||
----
|
||||
$ bx hd-public --index 0 < account
|
||||
xpub6BH1zcTuktiFu43rUZ2gXqLgzu5F3tLEeTQ5t6iE3aQtM2VMTxMcyLN9fYHiGhGpQe9QQYmqL2eYPFJ3vezHz5wzaSW4FiGrseNDR4LKqTy
|
||||
|
||||
$ bx hd-public --index 1 < account
|
||||
xpub6BH1zcTuktiFx6CzhPbGjG3UYQ13WR16CmtbPiagEKpEVtpyjshWyMaMV1cn7nUPUkgQHPVXJVqsrA8xWbGQDhohEcDFTEYMvYzwRD7Juf8
|
||||
----
|
||||
|
||||
The public keys can also be derived from their corresponding private keys using the((("Bitcoin Explorer","hd-to-public command")))((("hd-to-public command (bx)"))) +hd-to-public+ command.
|
||||
|
||||
----
|
||||
$ bx hd-private --index 0 < account | bx hd-to-public
|
||||
xpub6BH1zcTuktiFu43rUZ2gXqLgzu5F3tLEeTQ5t6iE3aQtM2VMTxMcyLN9fYHiGhGpQe9QQYmqL2eYPFJ3vezHz5wzaSW4FiGrseNDR4LKqTy
|
||||
|
||||
$ bx hd-private --index 1 < account | bx hd-to-public
|
||||
xpub6BH1zcTuktiFx6CzhPbGjG3UYQ13WR16CmtbPiagEKpEVtpyjshWyMaMV1cn7nUPUkgQHPVXJVqsrA8xWbGQDhohEcDFTEYMvYzwRD7Juf8
|
||||
----
|
||||
|
||||
We can generate a practically limitless number of keys in a deterministic chain, all derived from a single seed. This technique is used in many wallet applications to generate keys that can be backed up and restored with a single seed value. This is easier than having to back up the wallet with all its randomly generated keys every time a new key is created.
|
||||
|
||||
The seed can be encoded using the((("Bitcoin Explorer","mnemonic-encode command")))((("mnemonic-encode command (bx)"))) +mnemonic-encode+ command.
|
||||
|
||||
----
|
||||
$ bx hd-mnemonic < seed > words
|
||||
adore repeat vision worst especially veil inch woman cast recall dwell appreciate
|
||||
----
|
||||
|
||||
The seed can then be decoded using the((("Bitcoin Explorer","mnemonic-decode command")))((("mnemonic-decode command (bx)"))) +mnemonic-decode+ command.
|
||||
|
||||
----
|
||||
$ bx mnemonic-decode < words
|
||||
eb68ee9f3df6bd4441a9feadec179ff1
|
||||
----
|
||||
|
||||
Mnemonic encoding can make the seed easier to record and even remember.(((range="endofrange", startref="ix_appdx-bx-asciidoc0")))
|
@ -1,211 +0,0 @@
|
||||
[[appdx_sx]]
|
||||
[appendix]
|
||||
|
||||
== Available Commands with sx Tools
|
||||
|
||||
((("sx tools","commands in", id="ix_appdx-sx-asciidoc0", range="startofrange")))
|
||||
|
||||
----
|
||||
The sx commands are:
|
||||
|
||||
DEPRECATED
|
||||
ELECTRUM STYLE DETERMINISTIC KEYS AND ADDRESSES
|
||||
genaddr Generate a Bitcoin address deterministically from a wallet
|
||||
seed or master public key.
|
||||
genpriv Generate a private key deterministically from a seed.
|
||||
genpub Generate a public key deterministically from a wallet
|
||||
seed or master public key.
|
||||
mpk Extract a master public key from a deterministic wallet seed.
|
||||
newseed Create a new deterministic wallet seed.
|
||||
|
||||
EXPERIMENTAL
|
||||
APPS
|
||||
wallet Experimental command-line wallet.
|
||||
|
||||
OFFLINE BLOCKCHAIN
|
||||
HEADERS
|
||||
showblkhead Show the details of a block header.
|
||||
|
||||
OFFLINE KEYS AND ADDRESSES
|
||||
BASIC
|
||||
addr See Bitcoin address of a public or private key.
|
||||
embed-addr Generate an address used for embedding record of data into the
|
||||
blockchain
|
||||
get-pubkey Get the pubkey of an address if available.
|
||||
newkey Create a new private key.
|
||||
pubkey See the public part of a private key.
|
||||
validaddr Validate an address.
|
||||
BRAIN STORAGE
|
||||
brainwallet Make 256 bit bitcoin private key from an arbitrary passphrase.
|
||||
mnemonic Make 12 word mnemonic out of 128 bit electrum or bip32 seed.
|
||||
HD / BIP32
|
||||
hd-priv Create a private HD key from another HD private key.
|
||||
hd-pub Create an HD public key from another HD private or public key.
|
||||
hd-seed Create a random new HD key.
|
||||
hd-to-address Convert an HD public or private key to a Bitcoin address.
|
||||
hd-to-wif Convert an HD private key to a WIF private key.
|
||||
MULTISIG ADDRESSES
|
||||
scripthash Create BIP 16 script hash address from raw script hex.
|
||||
STEALTH
|
||||
stealth-addr See a stealth address from given input.
|
||||
stealth-initiate Initiate a new stealth payment.
|
||||
stealth-newkey Generate new stealth keys and an address.
|
||||
stealth-show-addr Show details for a stealth address.
|
||||
stealth-uncover Uncover a stealth address.
|
||||
stealth-uncover-secret Uncover a stealth secret.
|
||||
|
||||
OFFLINE TRANSACTIONS
|
||||
SCRIPTING
|
||||
mktx Create an unsigned tx.
|
||||
rawscript Create the raw hex representation from a script.
|
||||
set-input Set a transaction input.
|
||||
showscript Show the details of a raw script.
|
||||
showtx Show the details of a transaction.
|
||||
sign-input Sign a transaction input.
|
||||
unwrap Validates checksum and recovers version byte and original data
|
||||
from hexstring.
|
||||
validsig Validate a transaction input's signature.
|
||||
wrap Adds version byte and checksum to hexstring.
|
||||
|
||||
ONLINE (BITCOIN P2P)
|
||||
BLOCKCHAIN UPDATES
|
||||
sendtx-node Send transaction to a single node.
|
||||
sendtx-p2p Send tx to bitcoin network.
|
||||
|
||||
ONLINE (BLOCKCHAIN.INFO)
|
||||
BLOCKCHAIN QUERIES (blockchain.info)
|
||||
bci-fetch-last-height Fetch the last block height using blockchain.info.
|
||||
bci-history Get list of output points, values, and their spends
|
||||
from blockchain.info
|
||||
BLOCKCHAIN UPDATES
|
||||
sendtx-bci Send tx to blockchain.info/pushtx.
|
||||
|
||||
ONLINE (BLOCKEXPLORER.COM)
|
||||
BLOCKCHAIN QUERIES (blockexplorer.com)
|
||||
blke-fetch-transaction Fetches a transaction from blockexplorer.com
|
||||
|
||||
ONLINE (OBELISK)
|
||||
BLOCKCHAIN QUERIES
|
||||
balance Show balance of a Bitcoin address in satoshis.
|
||||
fetch-block-header Fetch raw block header.
|
||||
fetch-last-height Fetch the last block height.
|
||||
fetch-stealth Fetch a stealth information using a network connection
|
||||
to make requests against the obelisk load balancer backend.
|
||||
fetch-transaction Fetch a raw transaction using a network connection to
|
||||
make requests against the obelisk load balancer
|
||||
backend.
|
||||
fetch-transaction-index
|
||||
Fetch block height and index in block of transaction.
|
||||
get-utxo Get enough unspent transaction outputs from a given set
|
||||
of addresses to pay a given number of satoshis.
|
||||
history Get list of output points, values, and their spends for
|
||||
an address. grep can filter for just unspent outputs which can
|
||||
be fed into mktx.
|
||||
validtx Validate a transaction.
|
||||
BLOCKCHAIN UPDATES
|
||||
sendtx-obelisk Send tx to obelisk server.
|
||||
BLOCKCHAIN WATCHING
|
||||
monitor Monitor an address.
|
||||
watchtx Watch transactions from the network searching for a certain
|
||||
hash.
|
||||
OBELISK ADMIN
|
||||
initchain Initialize a new blockchain.
|
||||
|
||||
UTILITY
|
||||
EC MATH
|
||||
ec-add-modp Calculate the result of INTEGER + INTEGER.
|
||||
ec-multiply Multiply an integer and a point together.
|
||||
ec-tweak-add Calculate the result of POINT + INTEGER * G.
|
||||
FORMAT (BASE 58)
|
||||
base58-decode Convert from base58 to hex.
|
||||
base58-encode Convert from hex to base58.
|
||||
FORMAT (BASE58CHECK)
|
||||
base58check-decode Convert from base58check to hex.
|
||||
base58check-encode Convert from hex to base58check.
|
||||
decode-addr Decode a address from base58check form to internal RIPEMD
|
||||
representation.
|
||||
encode-addr Encode an address from internal RIPEMD representation to
|
||||
base58check form.
|
||||
FORMAT (WIF)
|
||||
secret-to-wif Convert a secret exponent value to Wallet Import Format.
|
||||
wif-to-secret Convert a Wallet Import Format to secret exponent value.
|
||||
HASHES
|
||||
ripemd-hash RIPEMD hash data from STDIN.
|
||||
sha256 Perform SHA256 hash of data.
|
||||
MISC
|
||||
qrcode Generate Bitcoin QR codes offline.
|
||||
SATOSHI MATH
|
||||
btc Convert Satoshis into Bitcoins.
|
||||
satoshi Convert Bitcoins into Satoshis.
|
||||
|
||||
See 'sx help COMMAND' for more information on a specific command.
|
||||
|
||||
----
|
||||
|
||||
Next, we look at some examples of using sx tools to experiment with keys and addresses.
|
||||
|
||||
Generate a new private key with the operating system's random number generator by using the +newkey+ command. We save the standard output into the file _private_key_:
|
||||
|
||||
----
|
||||
$ sx newkey > private_key
|
||||
$ cat private_key
|
||||
5Jgx3UAaXw8AcCQCi1j7uaTaqpz2fqNR9K3r4apxdYn6rTzR1PL
|
||||
----
|
||||
|
||||
Now, generate the public key from that private key using the +pubkey+ command. Pass the _private_key_ file into the standard input and save the standard output of the command into a new file _public_key_:
|
||||
|
||||
----
|
||||
$ sx pubkey < private_key > public_key
|
||||
$ cat public_key
|
||||
02fca46a6006a62dfdd2dbb2149359d0d97a04f430f12a7626dd409256c12be500
|
||||
----
|
||||
|
||||
We can reformat the +public_key+ as an address using the +addr+ command. We pass the +public_key+ into standard input:
|
||||
|
||||
----
|
||||
$ sx addr < public_key
|
||||
17re1S4Q8ZHyCP8Kw7xQad1Lr6XUzWUnkG
|
||||
----
|
||||
|
||||
The keys generated are so called type-0 nondeterministic keys. That means that each one is generated from a random number generator. The sx tools also support type-2 deterministic keys, where a "master" key is created and then extended to produce a chain or tree of subkeys.
|
||||
|
||||
First, we generate a "seed" that will be used as the basis to derive a chain of keys, compatible with the Electrum wallet and other similar implementations. We use the +newseed+ command to produce a seed value:
|
||||
|
||||
----
|
||||
$ sx newseed > seed
|
||||
$ cat seed
|
||||
eb68ee9f3df6bd4441a9feadec179ff1
|
||||
----
|
||||
|
||||
The seed value can also be exported as a word mnemonic that is human readable and easier to store and type than a hexadecimal string
|
||||
using the +mnemonic+ command:
|
||||
|
||||
----
|
||||
$ sx mnemonic < seed > words
|
||||
$ cat words
|
||||
adore repeat vision worst especially veil inch woman cast recall dwell appreciate
|
||||
----
|
||||
|
||||
The mnemonic words can be used to reproduce the seed using the +mnemonic+ command again:
|
||||
|
||||
----
|
||||
$ sx mnemonic < words
|
||||
eb68ee9f3df6bd4441a9feadec179ff1
|
||||
----
|
||||
|
||||
With the seed, we can now generate a sequence of private and public keys, a key chain. We use the +genpriv+ command to generate a sequence of private keys from a seed and the +addr+ command to generate the corresponding public key:
|
||||
|
||||
[source,bash]
|
||||
----
|
||||
$ sx genpriv 0 < seed
|
||||
5JzY2cPZGViPGgXZ4Syb9Y4eUGjJpVt6sR8noxrpEcqgyj7LK7i
|
||||
$ sx genpriv 0 < seed | sx addr
|
||||
1esVQV2vR9JZPhFeRaeWkAhzmWq7Fi7t7
|
||||
|
||||
$ sx genpriv 1 < seed
|
||||
5JdtL7ckAn3iFBFyVG1Bs3A5TqziFTaB9f8NeyNo8crnE2Sw5Mz
|
||||
$ sx genpriv 1 < seed | sx addr
|
||||
1G1oTeXitk76c2fvQWny4pryTdH1RTqSPW
|
||||
----
|
||||
|
||||
With deterministic keys we can generate and regenerate thousands of keys, all derived from a single seed in a deterministic chain. This technique is used in many wallet applications to generate keys that can be backed up and restored with a simple multiword mnemonic. This is easier than having to back up the wallet with all its randomly generated keys every time a new key is created.(((range="endofrange", startref="ix_appdx-sx-asciidoc0")))
|
Loading…
Reference in new issue