27 个版本
0.7.3 | 2023 年 3 月 8 日 |
---|---|
0.7.0 | 2022 年 8 月 6 日 |
0.6.7 | 2022 年 7 月 24 日 |
0.6.3 | 2022 年 3 月 27 日 |
0.1.1 | 2021 年 7 月 20 日 |
#2358 in 魔法豆
120 每月下载量
用于 melminter-mod
53KB
947 行
melwallet-cli(ent)
用于与 Themelio 钱包守护进程通信的事实上使用的工具,melwalletd
。 melwallet-cli
格式化和发送请求到区块链,并在必要时提示用户。此工具旨在提供直接与 melwalletd
REST API 交互的灵活性,并具有许多额外的好处,包括
- 有用的帮助信息
- 自动响应输出格式化
- 自动交易准备和请求格式化
melwallet-client
还提供 Rust 库 API,但当前尚不稳定。
安装
melwallet-client
是一个 Rust crate,所以最简单的方法是使用 cargo
安装。如果尚未安装,请确保也安装 melwalletd
cargo install --locked melwallet-cli melwalletd
有关此软件的快速入门,请参阅 Themelio 文档页面上的此快速指南
使用 melwallet-cli
要显示 melwallet-cli
功能的完整描述,请使用 --help
标志
$ melwallet-cli --help
melwallet-client
USAGE:
melwallet-cli <SUBCOMMAND>
OPTIONS:
-h, --help Print help information
SUBCOMMANDS:
autoswap Automatically executes arbitrage trades on the core, "triangular"
MEL/SYM/NOM-DOSC pairs
create Create a wallet
export-sk Exports the secret key of a wallet. Will read password from stdin
generate-autocomplete Generate bash autocompletions
help Print this message or the help of the given subcommand(s)
import Provide a secret key to import an existing wallet
liq-deposit Supplies liquidity to Melswap
list List all available wallets
lock Locks a wallet down again
network-summary Show the summary of the network connected to the associated
melwalletd instance
pool Checks a pool
send Send a transaction to the network
send-faucet Send a 1000 MEL faucet transaction for a testnet wallet
send-raw Sends a raw transaction in hex, with no customization options
stake Stakes a certain number of syms
summary Details of a wallet
swap Swaps money from one denomination to another
unlock Unlocks a wallet. Will read password from stdin
wait-confirmation Wait for a particular transaction to confirm
如上所述,所有 melwallet-cli/melwalletd 组合的功能都可通过子命令使用。查看其中一个子命令,您将看到更多有用的信息
$ melwallet-cli send --help
melwallet-cli-send x.x.x
Send a transaction to the network
USAGE:
melwallet-cli send [FLAGS] [OPTIONS] -w <wallet>
FLAGS:
-h, --help Prints help information
--raw
-V, --version Prints version information
OPTIONS:
--add-covenant <add-covenant>... Additional covenants. This often must be specified if we are spending coins
that belong to other addresses, like covenant coins
--endpoint <endpoint> HTTP endpoint of a running melwalletd instance [default: 127.0.0.1:11773]
--force-spend <force-spend>... Force the selection of a coin
--to <to>... A string specifying who to send money to, in the format
"dest,amount[,denom[,additional_data]]". For example, --to $ADDRESS,1 sends
1 µMEL to $ADDRESS. Can be specified multiple times to send money to
multiple addresses
-w <wallet> Name of the wallet to create or use
我们一直在努力使这些信息尽可能有用,如果您有任何建议,请通过 matrix 或 discord 发给我们一条消息
基本用法
作为 melwalletd
的瘦客户端,melwallet-cli
需要访问 melwalletd
的一个实例。有关“我的第一次交易”教程的内容涉及运行 melwalletd
,但简而言之,你可以
- 运行一个 主网
melwalletd
实例,本地状态存储在~/.wallets
$ melwalletd --wallet-dir ~/.wallets
- 或运行一个 测试网
melwalletd
实例$ melwalletd --network testnet --wallet-dir ~/.wallets
通常,你想要连接到主网以访问“真实”的 MEL、SYM、covenants 等。使用测试网的优点是可以从水龙头功能获得无限的“玩钱”,我们将很快介绍这一点。
本文档的其余部分假设 melwalletd
在后台本地运行。
创建
$ melwallet-cli create -w test_wallet
Enter password: <your password>
Wallet name: test_wallet (locked)
Network: testnet
Address: t20aexrbvnxgcpmyzbzcemv8651s40rqe0we8a33ebadyrhb87k930
Balance: 0.000000 MEL
Staked: 0.000000 SYM
如你所见,我们使用了带有 --w
标志的 create
子命令,该标志是 --wallet
的缩写,用于创建名为 test_wallet
的钱包。此命令输出了新创建的钱包的格式化摘要。
send-faucet
(仅限测试网)
$ melwallet-cli send-faucet -w test_wallet
Transaction hash: c55cb04275fe0d6c618a51e04eb82b1a43487b499d8cca28d5d7ec2247f5047d
(wait for confirmation with melwallet-cli wait-confirmation -w test_wallet c55cb04275fe0d6c618a51e04eb82b1a43487b499d8cca28d5d7ec2247f5047d)
当需要时,可以使用 send-faucet
动词从网络中收集 1001 个伪造的 MEL
。此动词输出交易哈希,以及一个使用 wait-confirmation
动词的 melwallet-cli
命令。
melwallet-cli wait-confirmation -w test_wallet c55cb04275fe0d6c618a51e04eb82b1a43487b499d8cca28d5d7ec2247f5047d
如果使用此命令,终端将等待交易被 Themelio 区块链接受。
摘要
$ melwallet-cli summary -w test_wallet
Wallet name: test_wallet (locked)
Network: testnet
Address: t20aexrbvnxgcpmyzbzcemv8651s40rqe0we8a33ebadyrhb87k930
Balance: 1001.000000 MEL
Staked: 0.000000 SYM
此命令输出名为 --w
、test_wallet
的钱包摘要,包括该钱包所属的 network
、与此钱包关联的 address
、balance
(包含来自 send-faucet
交易的 MEL
)和在网络中抵押的 SYM
的数量;与动词产生的摘要相同,create
发送
以下命令将 0.0001 MEL 发送到 t22272fg9r0k8k09qj06drzzjq9e0rw3asxfs1zrnaccwv5j6gq5tg
,附带与硬币关联的“附加数据”68656c6c6f20776f726c64
。
$ melwallet-cli send -w testing123 --to t22272fg9r0k8k09qj06drzzjq9e0rw3asxfs1zrnaccwv5j6gq5tg,0.0001,MEL,68656c6c6f20776f726c64
TRANSACTION RECIPIENTS
Address Amount Additional data
t22272fg9r0k8k09qj06drzzjq9e0rw3asxfs1zrnaccwv5j6gq5tg 0.000100 MEL "68656c6c6f20776f726c64"
t22272fg9r0k8k09qj06drzzjq9e0rw3asxfs1zrnaccwv5j6gq5tg 124.999685 MEL ""
t22272fg9r0k8k09qj06drzzjq9e0rw3asxfs1zrnaccwv5j6gq5tg 124.999686 MEL ""
(network fees) 0.000254 MEL
Proceed? [y/N] y
Transaction hash: 818336401d0d1303d182aa83926f9d0fc288e12cdbf5d473327a255babed55f6
(wait for confirmation with melwallet-cli wait-confirmation -w testing123 818336401d0d1303d182aa83926f9d0fc288e12cdbf5d473327a255babed55f6)
发送命令的 --to
标志可能有点令人困惑。它最多是四个逗号分隔的值
- 一个 address(covenant 哈希);在示例中
t22272fg9r0k8k09qj06drzzjq9e0rw3asxfs1zrnaccwv5j6gq5tg
- 发送的 value,在本例中为
0.0001
- 发送的代币的 denomination,在本例中为
MEL
- 附加到将包含要发送的资金的硬币的 additional data。在 Themelio 中,每个硬币/UTXO 都有一个附加数据字段,可以用作 covenant 输入,或者只是将任意数据附加到付款中。
面额和附加数据是可选的,但如果只提供其中之一,则必须是面额。例如,
--to t22272fg9r0k8k09qj06drzzjq9e0rw3asxfs1zrnaccwv5j6gq5tg,0.0001
意味着向 t22272fg9r0k8k09qj06drzzjq9e0rw3asxfs1zrnaccwv5j6gq5tg
发送 0.0001 MEL,并带有 空 的附加数据,而
--to t22272fg9r0k8k09qj06drzzjq9e0rw3asxfs1zrnaccwv5j6gq5tg,0.0001,SYM
意味着向同一地址发送 0.0001 SYM,再次带有空附加数据。
高级用法
melwallet-cli
还可以用于在 Themelio 上部署称为 covenants 的脚本。有关部署 covenants 的更多信息,请参阅此处。
依赖关系
~23–62MB
~1M SLoC