@abcpros/bitcore-wallet 中文文档教程

发布于 3年前 浏览 24 项目主页 更新于 3年前

Bitcore Wallet

NPM Package

一个简单的命令行界面钱包,使用 Bitcore Wallet Service 及其官方客户端库 Bitcore Wallet Client

这可用于操作比特币和比特币现金钱包。

Quick Guide

# Use -h or BWS_HOST to setup the BWS URL (defaults to localhost:3001)
#
# Start a local BWS instance be doing:
# git clone https://github.com/bitpay/bitcore/tree/master/packages/bitcore-wallet-service.git bws
# cd bws; npm install; npm start

cd bin

# Create a 2-of-2 wallet (~/.wallet.dat is the default filename where the wallet critical data will be stored)
#
# TIP: add -t for testnet, and -p to encrypt the credentials file
wallet create 'my wallet' 2-2
  * Secret to share:
    JevjEwaaxW6gdAZjqgWcimL525DR8zQsAXf4cscWDa8u1qKTN5eFGSFssuSvT1WySu4YYLYMUPT

# Check the status of your wallet
wallet status

  * Wallet my wallet [livenet]: 2-of-2 pending
    Missing copayers: 1

# Use -f or WALLET_FILE to setup the wallet data file

# Join the wallet as another copayer (add -p to encrypt credentials file)
wallet -f pete.dat join JevjEwaaxW6gdAZjqgWcimL525DR8zQsAXf4cscWDa8u1qKTN5eFGSFssuSvT1WySu4YYLYMUPT

export WALLET_FILE=pete.dat
wallet status

# Generate addresses to receive money
wallet address
  * New Address 3xxxxxx

# Check your balance
wallet balance

# Spend coins. Amount can be specified in btc, bit or sat (default)
wallet send 1xxxxx 1000bit "1000 bits to mother"
  * Tx created: ID 01425517364314b9ac6017-e97d-46d5-a12a-9d4e5550abef [pending]
    RequiredSignatures: 2

# You can use 1000bit or 0.0001btc or 100000sat. (Set BIT_UNIT to btc/sat/bit to select output unit).

It is also possible to use Payment Protocol or BIP21. Examples:

wallet send 'bitcoin:?r=https://bitpay.com/i/8rR7ydnLfQGqnRW1mqvXxJ'
wallet send 'bitcoin:1N4zjmp1ojRborDiAu62MyCpaz9wjhPLM?amount=1'

# List pending TX Proposals
wallet txproposals
  * TX Proposals:
    abef ["1000 bits to mother" by pete] 1,000 bit => 1xxxxx
      Missing signatures: 2

# Sign or reject TXs from other copayers
wallet -f pete.dat reject <id>
wallet -f pete.dat sign <id>

# List transaction history
wallet history
  a few minutes ago: => sent 1,000 bit ["1000 bits to mother" by pete] (1 confirmations)
  a day ago: <= received 1,400 bit (48 confirmations)
  a day ago: <= received 300 bit (62 confirmations)

# List all commands:
wallet --help

Password protection

可以(并推荐)加密钱包的凭据(.dat 文件)。 这是通过将 -p 参数添加到 joincreategenkey 来完成的。 将以交互方式询问密码。 以下使用凭据的命令将需要密码才能工作。

基于密码的密钥派生函数 2 (PBKDF2) 用于派生密钥以加密数据。 AES 用于执行实际加密,使用 SJCL 的实现。

Airgapped Operation

支持气隙(未连接)设备。 如果需要最大的安全性以防止私钥被泄露,此设置可能很有用。 在此设置中,安装的设备没有网络访问权限,并且交易是离线签署的。 可以使用proxy 设备从 BWS 提取交易,然后下载到 pendrive 以移动到 air-gapped 设备,在那里签名,然后移回 proxy 设备将被送回 BWS。 请注意,私钥是在气隙设备中离线生成的。

# On the Air-gapped device

# Generate extended private key (add -t for testnet)
airgapped$ wallet genkey
  * Livenet Extended Private Key Created.

airgapped$ wallet export -o toproxy --nosign
  * Wallet data saved at toproxy without signing capability.


# On the proxy machine
proxy$ wallet import toproxy
  * Wallet Imported without signing capability.
proxy$ wallet join <secret>    # Or wallet create 
proxy$ wallet address
proxy$ wallet balance

# It is not possible to sign transactions from the proxy device
proxy$ wallet sign
  [Error: You do not have the required keys to sign transactions]

# Export pending transaction to be signed offline
proxy$ wallet txproposals -o txproposals.dat

## Back to air-gapped device

# Sign them
airgapped$ wallet airsign txproposals.dat -o signatures.dat

# NOTE: To allow the airgapped device to check the transaction proposals being signed, the public keys of the copayers will be imported from the txproposals archive. That information is exported automatically by the proxy machine, and encrypted using copayer's xpriv derivatives.

## Back to proxy machine

# Send signatures to BWS
proxy$ wallet sign -i signatures.dat
  Transaction 014255.... signed by you.

Contributing

有关如何贡献的信息,请参阅主 bitcore 存储库上的 CONTRIBUTING.md

License

代码根据 MIT 许可证发布。

版权所有 2013-2019 BitPay, Inc. Bitcore 是 BitPay, Inc. 维护的商标。

Bitcore Wallet

NPM Package

A simple Command Line Interface Wallet using Bitcore Wallet Service and its official client lib Bitcore Wallet Client.

This can be used to operate Bitcoin and Bitcoin Cash wallets.

Quick Guide

# Use -h or BWS_HOST to setup the BWS URL (defaults to localhost:3001)
#
# Start a local BWS instance be doing:
# git clone https://github.com/bitpay/bitcore/tree/master/packages/bitcore-wallet-service.git bws
# cd bws; npm install; npm start

cd bin

# Create a 2-of-2 wallet (~/.wallet.dat is the default filename where the wallet critical data will be stored)
#
# TIP: add -t for testnet, and -p to encrypt the credentials file
wallet create 'my wallet' 2-2
  * Secret to share:
    JevjEwaaxW6gdAZjqgWcimL525DR8zQsAXf4cscWDa8u1qKTN5eFGSFssuSvT1WySu4YYLYMUPT

# Check the status of your wallet
wallet status

  * Wallet my wallet [livenet]: 2-of-2 pending
    Missing copayers: 1

# Use -f or WALLET_FILE to setup the wallet data file

# Join the wallet as another copayer (add -p to encrypt credentials file)
wallet -f pete.dat join JevjEwaaxW6gdAZjqgWcimL525DR8zQsAXf4cscWDa8u1qKTN5eFGSFssuSvT1WySu4YYLYMUPT

export WALLET_FILE=pete.dat
wallet status

# Generate addresses to receive money
wallet address
  * New Address 3xxxxxx

# Check your balance
wallet balance

# Spend coins. Amount can be specified in btc, bit or sat (default)
wallet send 1xxxxx 1000bit "1000 bits to mother"
  * Tx created: ID 01425517364314b9ac6017-e97d-46d5-a12a-9d4e5550abef [pending]
    RequiredSignatures: 2

# You can use 1000bit or 0.0001btc or 100000sat. (Set BIT_UNIT to btc/sat/bit to select output unit).

It is also possible to use Payment Protocol or BIP21. Examples:

wallet send 'bitcoin:?r=https://bitpay.com/i/8rR7ydnLfQGqnRW1mqvXxJ'
wallet send 'bitcoin:1N4zjmp1ojRborDiAu62MyCpaz9wjhPLM?amount=1'

# List pending TX Proposals
wallet txproposals
  * TX Proposals:
    abef ["1000 bits to mother" by pete] 1,000 bit => 1xxxxx
      Missing signatures: 2

# Sign or reject TXs from other copayers
wallet -f pete.dat reject <id>
wallet -f pete.dat sign <id>

# List transaction history
wallet history
  a few minutes ago: => sent 1,000 bit ["1000 bits to mother" by pete] (1 confirmations)
  a day ago: <= received 1,400 bit (48 confirmations)
  a day ago: <= received 300 bit (62 confirmations)

# List all commands:
wallet --help

Password protection

It is possible (and recommeded) to encrypt the wallet's credentials (.dat file). this is done be adding the -p parameter to join or create or genkey. The password will be asked interactively. Following commands that use the crendetials will require the password to work.

Password-based key derivation function 2 (PBKDF2) is used to derive the key to encrypt the data. AES is used to do the actual encryption, using the implementation of SJCL.

Airgapped Operation

Air gapped (non connected) devices are supported. This setup can be useful if maximum security is needed, to prevent private keys from being compromised. In this setup, a device is installed without network access, and transactions are signed off-line. Transactions can be pulled from BWS using a proxy device, then downloaded to a pendrive to be moved to the air-gapped device, signed there, and then moved back the proxy device to be sent back to BWS. Note that Private keys are generated off-line in the airgapped device.

# On the Air-gapped device

# Generate extended private key (add -t for testnet)
airgapped$ wallet genkey
  * Livenet Extended Private Key Created.

airgapped$ wallet export -o toproxy --nosign
  * Wallet data saved at toproxy without signing capability.


# On the proxy machine
proxy$ wallet import toproxy
  * Wallet Imported without signing capability.
proxy$ wallet join <secret>    # Or wallet create 
proxy$ wallet address
proxy$ wallet balance

# It is not possible to sign transactions from the proxy device
proxy$ wallet sign
  [Error: You do not have the required keys to sign transactions]

# Export pending transaction to be signed offline
proxy$ wallet txproposals -o txproposals.dat

## Back to air-gapped device

# Sign them
airgapped$ wallet airsign txproposals.dat -o signatures.dat

# NOTE: To allow the airgapped device to check the transaction proposals being signed, the public keys of the copayers will be imported from the txproposals archive. That information is exported automatically by the proxy machine, and encrypted using copayer's xpriv derivatives.

## Back to proxy machine

# Send signatures to BWS
proxy$ wallet sign -i signatures.dat
  Transaction 014255.... signed by you.

Contributing

See CONTRIBUTING.md on the main bitcore repo for information about how to contribute.

License

Code released under the MIT license.

Copyright 2013-2019 BitPay, Inc. Bitcore is a trademark maintained by BitPay, Inc.

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文