钱包 RPC
本文档提供了Chia钱包RPC API 的全面参考(不包含DID及NFT,这两者有专门的章节介绍)。
Note about Windows command escaping
This document will use Linux/MacOS RPC syntax. When running rpc commands on Windows, you'll need to escape all quotes with backslashes.
For example, here is a typical RPC command on Linux and MacOS:
chia rpc wallet create_new_wallet '{"wallet_type": "nft_wallet"}'
To run the same command on Windows, you need to escape the quotes with backslashes. In other words, add a \ before each double quote, such that:
"fee"
becomes \"fee\"
"1000"
becomes \"1000\"
etc
密钥管理
add_key
功能:从给定的助记词创建一个新的密钥 (钱包/指纹)
用法: chia rpc wallet [OPTIONS] add_key [REQUEST]
Options:
Short Command | Long Command | Type | Required | Description |
---|---|---|---|---|
-j | --json-file | FILENAME | False | Optionally instead of REQUEST you can provide a json file containing the request data |
-h | --help | None | False | Show a help message and exit |
Request Parameters:
Flag | Type | Required | Description |
---|---|---|---|
mnemonic | TEXT ARRAY | True | 一个24字助记词,表示为数组 |
Example
chia rpc wallet add_key '{"mnemonic": ["hint", "dice", "session", "fun", "budget", "strong", "album", "lava", "tackle", "sudden", "garage", "people", "bundle", "federal", "chest", "process", "vicious", "behave", "nephew", "zero", "vital", "ocean", "artist", "lawsuit"]}'
Response:
{
"fingerprint": 874731676,
"success": true
}
check_delete_key
功能:显示指纹是否有余额,以及指纹是否用于耕种或联合耕种奖励。 这有助于确定是否可以安全地删除一个密钥而不需要先备份它
用法: chia rpc wallet [OPTIONS] check_delete_key [REQUEST]
Options:
Short Command | Long Command | Type | Required | Description |
---|---|---|---|---|
-j | --json-file | FILENAME | False | Optionally instead of REQUEST you can provide a json file containing the request data |
-h | --help | None | False | Show a help message and exit |
Request Parameters:
Flag | Type | Required | Description |
---|---|---|---|
fingerprint | NUMBER | True | The wallet's fingerprint, obtainable by running chia wallet show |
max_ph_to_search | NUMBER | False | 要搜索的拼图哈希的最大数量[默认:100] |
Example
chia rpc wallet check_delete_key '{"fingerprint": 874731676, "max_ph_to_search": 200}'
Response:
{
"fingerprint": 874731676,
"success": true,
"used_for_farmer_rewards": false,
"used_for_pool_rewards": false,
"wallet_balance": false
}
delete_all_keys
功能:从钱包中删除所有密钥
用法:chia rpc wallet [OPTIONS] delete_all_keys [REQUEST]
Options:
Short Command | Long Command | Type | Required | Description |
---|---|---|---|---|
-j | --json-file | FILENAME | False | Optionally instead of REQUEST you can provide a json file containing the request data |
-h | --help | None | False | Show a help message and exit |
Request Parameters: None
这将删除所有密钥,无需任何进一步提示。 Prior to running this command, be sure to either verify that each key can be safely deleted by running check_delete_key, or back up each seed phrase for later recovery
Example
chia rpc wallet delete_all_keys
Response:
{
"success": true
}
delete_key
功能:基于钱包指纹删除一个密钥
用法:chia rpc wallet [OPTIONS] delete_key [REQUEST]
Options:
Short Command | Long Command | Type | Required | Description |
---|---|---|---|---|
-j | --json-file | FILENAME | False | Optionally instead of REQUEST you can provide a json file containing the request data |
-h | --help | None | False | Show a help message and exit |
Request Parameters:
Flag | Type | Required | Description |
---|---|---|---|
fingerprint | NUMBER | True | The wallet's fingerprint, obtainable by running chia wallet show |
Example
chia rpc wallet delete_key '{"fingerprint": 874731676}'
Response:
{
"success": true
}