钱包 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
}
generate_mnemonic
功能:生成一组随机的24字助记词
用法: chia rpc wallet [OPTIONS] generate_mnemonic [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
Example
chia rpc wallet generate_mnemonic
Response:
{
"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"
],
"success": true
}
get_logged_in_fingerprint
功能:获取当前登录的钱包的指纹。
用法: chia rpc wallet [OPTIONS] get_logged_in_fingerprint [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
Example
chia rpc wallet get_logged_in_fingerprint
Response:
{
"fingerprint": 2818719465,
"success": true
}
get_private_key
功能:显示关于密钥的公共和私有信息
用法: chia rpc wallet [OPTIONS] get_private_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 |
This RPC will show the private key and seed phrase for the given fingerprint. Use with caution. Use with caution.
Example
chia rpc wallet get_private_key '{"fingerprint": 2473794447}'
Response:
{
"private_key": {
"farmer_pk": "8c65856685323f149a651e6cbe068ece36f87a84efa16246b0eef65ac586a30fb678878bd4364d52c432fbb77838cbf6",
"fingerprint": 2473794447,
"pk": "b73cf2471b10a7ba839616aff0ab1cb319d9d3a77ee26ff88ec1c8e645468eb0b7653518b85e5dd0df7cf50d8612b978",
"pool_pk": "845ff087376ffecf83950485d63ffed1cc73f36daf018deb4fbd2f05e7198b07521486274d82ecc4f5a2eaae63dfd0a7",
"seed": "arrest legend bounce attend rebel blade palace bean dry shell nice bubble coil cook token nerve visa december hero garment grid attend nerve certain",
"sk": "0665913196501420c0fe2de6b5ce7b25f749d52dcbf997b069bb2ea8438c6c3c"
},
"success": true
}
get_public_keys
功能: Show all public key fingerprints stored in the OS keyring. Note that the keyring must be unlocked in order to run this RPC 请注意,必须解锁密钥环才能运行此RPC。
用法: chia rpc wallet [OPTIONS] get_public_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
Example
chia rpc wallet get_public_keys
Response:
{
"public_key_fingerprints": [2104826454, 3792481086, 2818719465, 2121994410],
"success": true
}
log_in
功能:使用指定的密钥登录钱包。
用法: chia rpc wallet [OPTIONS] log_in [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 log_in '{"fingerprint": 2818719465}'
Response:
{
"fingerprint": 2818719465,
"success": true
}
钱包节点
get_auto_claim
Functionality: Show the auto claim settings for all types of claims, including clawback
Usage: chia rpc wallet [OPTIONS] get_auto_claim [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
Note that the auto claim settings are configurable in ~/.chia/mainnet/config/config.yaml
in the auto_claim:
section.
Example
chia rpc wallet get_auto_claim
Response:
{
"batch_size": 50,
"enabled": false,
"min_amount": 0,
"success": true,
"tx_fee": 0
}
get_height_info
功能:显示当前钱包同步的区块高度。
用法: chia rpc wallet [OPTIONS] get_height_info [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
Example
chia rpc wallet get_height_info
Response:
{
"height": 2863319,
"success": true
}