# 管理钱包
通过钱包功能,您可以创建、管理本地账户和 worker key、设置默认账户、查看所有账户、重置 keystore 文件密码、导入私钥等。
wallet 命令如下表所示:
命令 | 说明 |
---|---|
topio wallet createAccount | 创建账户。 |
topio wallet importAccount | 导入账户。 |
topio wallet createKey | 为账户创建 worker key。 |
topio wallet listAccounts | 查看钱包里所有账户。 |
topio wallet setDefaultAccount | 设置默认账户,用来发送交易。 |
topio wallet resetKeystorePwd | 重置 keystore 文件密码。 |
topio wallet exportAccount | 导出私钥。 |
# 创建账户
在本地创建账户,可同时创建多个账户。
每个账户会有唯一一对公私钥对,称之为 owner key,它拥有账户的全部权限,包括且不限于发交易、挖矿等。
注意
建议您在创建账户后立刻备份您的 keystore 文件。
如果您设置了 keystore 文件密码,请记住密码,如果丢失了密码,您将无法使用该账户。且系统没有“忘记密码”选项,只可以通过密码提示找回密码。
请安全保管您的 keystore 文件,不要与其他人分享您的 keystore 文件和文件密码,以免造成资产损失!
keystore 文件存储目录:
root 用户:
/root/topnetwork/keystore
非 root 用户:
/home/您登陆服务器的用户名/topnetwork/keystore
请求方式
topio wallet createAccount
请求参数
无。
选项
选项名称 | 默认值 | 类型 | 说明 |
---|---|---|---|
-p,--password | - | String | 创建一个设置了密码的账户。如不添加此选项,系统将以无密码的形式创建一个账户。 密码由数字和字母组成,8-16 字符。 |
-f, --pwd_file_path | - | - | 以密码文件的方式创建账户。 |
-h, --help | - | - | 查看命令帮助信息。 |
返回参数
参数名称 | 类型 | 说明 |
---|---|---|
Account Address | String | 为了简便实用,采用“账户地址”替代公钥从而代表账户。 您可以公开您的账户地址,其他人需要账户地址和您进行互动,例如给您的账号地址转账,或者您通过账号地址向别人发送一笔交易。 此处创建的为普通用户账户地址,以"T80000"为标识开头。 |
Owner public-key | String | 账户公钥,和私钥总是成对出现,私钥存储在 owner keystore 文件中,关于 keystore 文件,请参见 账户协议 中相关内容。 公钥用于加密及验签。 |
请求样例
topio wallet createAccount
返回样例
成功返回
Successfully create an account locally! You can share your public key and account address with anyone. Others need them to interact with you! You must nerver share the private key or account keystore file with anyone! They control access to your funds! You must backup your account keystore file! Without the file, you will not be able to access the funds in your account! You must remember your password if you set it! Without the password, it's impossible to use the keystore file! Account Address: T800002276a7d58218ac4978733e5cca927a7d86cb7c87 Owner public-Key: BAW5r2JJd/j7Wr6iISO7ki5+YE2OKflaG7dVbV+u1EkPpcAqe3Ou10EPNlKjlI4EsAJR9LBc+Fv9DC1Znm8rKcU=
失败返回
输入不符合格式要求的密码返回:
Password error! Please set a password for the account keystore file. The password must consist of Numbers and Letters, 8 to 16 characters.
# 导入账户
通过导入私钥的方式导入账户。
请求方式
topio wallet importAccount
请求参数
无。
选项
选项名称 | 默认值 | 类型 | 说明 |
---|---|---|---|
-p,--password | - | String | 导入账户时为该账户设置密码。如不添加此选项,系统将以无密码的形式导入账户。 密码由数字和字母组成,8-16 字符。 |
-h, --help | - | - | 查看命令帮助信息。 |
返回参数
参数名称 | 类型 | 说明 |
---|---|---|
Account Address | String | 导入的私钥所对应的账户地址。 |
Public-Key | String | 公钥,用于加密及验签。 |
请求样例
topio wallet importAccount
运行命令后,根据提示输入私钥。
返回样例
Import successfully.
Account Address: T80000968927100f3cb7b23e8d477298311648978d8613
Public-Key: BK2CfxnSP0cL9/dbi6b3krWUlQP1jP4EIHu5Y5c2vMBNLMYMOE8K3mqOubDPQXBXc/D4ydtR0LDyWUEyxHO/ZZU=
# 创建 worker key
给一个已存在的账户绑定多把公私钥对,这种公私钥对称之为 worker key。它可以被授予挖矿的权限,但没有发交易的权限。我们推荐您在线使用 worker key 挖矿,离线保管 owner key,让您的资产更加安全。
请求方式
topio wallet createKey
请求参数
参数名称 | 是否必选 | 默认值 | 类型 | 说明 |
---|---|---|---|---|
account_addr | 否 | 默认账户 | String | worker key 所属账户。如不指定,将为默认账户创建 worker key。 |
选项
选项名称 | 默认值 | 类型 | 说明 |
---|---|---|---|
-p, --password | - | String | 创建一个设置了密码的 worker key;如果不添加此选项,则无需密码即可创建 worker key。 密码由数字和字母组成,8-16 字符。 |
-f, --pwd_file_paty | - | - | 以密码文件的方式创建 worker key。 |
-h, --help | - | - | 查看命令帮助信息。 |
返回参数
参数名称 | 类型 | 说明 |
---|---|---|
Public Key | String | 公钥,和私钥总是成对出现。 用于加密及验签。 |
worker public_key | String | worker key 的公钥。 |
请求样例
topio wallet createKey -p
返回样例
成功返回
Successfully create a worker keystore file! You can share your public key and account address with anyone. Others need them to interact with you! You must nerver share the private key or account keystore file with anyone! They control access to your funds! You must backup your account keystore file! Without the file, you will not be able to access the funds in your account! You must remember your password if you set it! Without the password, it's impossible to use the keystore file! Account Address: T800002276a7d58218ac4978733e5cca927a7d86cb7c87 worker public-key: BAW5r2JJd/j7Wr6iISO7ki5+YE2OKflaG7dVbV+u1EkPpcAqe3Ou10EPNlKjlI4EsAJR9LBc+Fv9DC1Znm8rKcU=
失败返回
输入不符合格式要求的密码返回:
Password error!
# 列出钱包中所有账户
列出钱包中所有账户。
请求方式
topio wallet listAccounts
请求参数
无。
选项
选项名称 | 默认值 | 类型 | 说明 |
---|---|---|---|
-h,--help | - | - | 查看命令帮助信息。 |
返回参数
参数名称 | 类型 | 说明 |
---|---|---|
account | String | 账户地址。如账户地址后标记"default account",表示此账户是当前正在使用的账户。 |
owner public-key | String | 账户 base58 格式公钥。如 owner public-key 后标记"registered as minerkey",表示此 owner key 被注册成为 miner key。 |
balance | Uint64 | 账户余额,单位 TOP。 请注意 balance 显示为"-"和"0"的区别:
|
nonce | Uint64 | 该账户最新共识成功的交易序号,唯一。 |
worker public-key | String | 此账户的 worker key 的 base58 格式公钥列表。如 worker public-key 后标记"registered as minerkey",表示此 worker key 被注册成为 miner key。 |
请求样例
topio wallet listAccounts
返回样例
成功返回
No default account account #0: T8000066ab344963eaa071f9636faac26b0d1a39900325 owner public-key: BFPQ1X11sm+OU9ua3DeEnzwYb7npoa+uhJXcdi4i205y7PaXzfDwAUGGdaV6qj3k2V7lUQiFDuofl5CaFhjaXlQ= balance: 10000000.000000 TOP nonce: 0 worker public-key list: public key #0: BG2KavysdOhOzfHPIHR2kBpq2SMw/M+n4S0Q90PS7bVZ9tV2ipPsbKeQmgyBx+BErOH0kgnGFvq++3rj3v6YxfA= ------------------------------------------------------ account #1: T8000085a8e8acd53c72dca85dcb002a6710796975b4ba owner public-key: BJL6rIirL1m7ox+hKHymSISULh8HPYI8772Wq7h0oUga8exzuRrTR599inROGNkGK5O8buwFhe+E2WKyYD3l8tE= balance: 30000000.000000 TOP nonce: 0
失败返回
There is no account in wallet.
# 设置默认账户
以下场景需要设置默认账户:
钱包中有多个账户,需要设置一个默认账户,用于发送交易。
钱包中只有一个账户,但是账户设有密码,需要将此账户设置为默认账户,用来发送交易。
切换发送交易的账户。
在 TOPIO 前台 30 分钟内无任何操作(查询或发送交易),您设置的默认账户将失效,需要重新设置一个默认账户。
请求方式
topio wallet setDefaultAccount
请求参数
参数名称 | 是否必选 | 默认值 | 类型 | 说明 |
---|---|---|---|---|
account_addr | 是 | - | String | 账户地址。 |
选项
选项名称 | 默认值 | 类型 | 说明 |
---|---|---|---|
-h, --help | - | - | 查看命令帮助信息。 |
返回参数
无。
请求样例
topio wallet SetDefaultAccount T8000085a8e8acd53c72dca85dcb002a6710796975b4ba
返回样例
成功返回
Set default account successfully.
失败返回
账户 owner key 不存在:
The account's owner keystore file does not exist in wallet.
密码错误或者 owner key 无密码:
Password error! Hint: Set default account failed.
# 重置 keystore 文件密码
支持重置 owner keystore 和 worker keystore 文件密码。
请求方式
topio wallet resetKeystorePwd
请求参数
参数名称 | 是否必选 | 默认值 | 类型 | 说明 |
---|---|---|---|---|
public_key | 是 | - | String | owner key 或者 worker key 的公钥。 |
选项
选项名称 | 默认值 | 类型 | 说明 |
---|---|---|---|
-h, --help | - | - | 查看命令帮助信息。 |
返回参数
无。
请求样例
旧格式:
topio wallet resetKeystorePwd BERrbuiBZ66gYHHhx2/4OzqHwqC+DrJRh7vdPz5e8fHD+OwGhgmRjnoNbyM2rnI9eXTjuSOvAGG5J1tOAyMFnVQ=
新格式:
topio wallet resetKeystorePwd ad827f19d23f470bf7f75b8ba6f792b5949503f58cfe04207bb9639736bcc04d2cc60c384f0ade6a8eb9b0cf41705773f0f8c9db51d0b0f2594132c473bf6595
返回样例
成功返回
Successfully reset password!
失败返回
输入错误旧密码返回:
Password error! Hint: basketball Set default account failed.
# 导出私钥
导出并展示钱包私钥和 keystore 文件内容。导出后,您可复制并保存在本地。
请求方式
topio wallet exportAccount
请求参数
无。
选项
选项名称 | 默认值 | 类型 | 说明 |
---|---|---|---|
-h,--help | - | - | 查看命令帮助信息。 |
返回参数
参数名称 | 类型 | 说明 |
---|---|---|
Account Address | String | 账户地址。当导出 keystore 文件时,此处会打印对应的账户地址。 |
Private-Key | String | key 的私钥。 |
请求样例
topio wallet exportAccount T80000968927100f3cb7b23e8d477298311648978d8613
返回样例
关于 Keystore 文件格式,可参见 账户协议。
Export successfully.
Keystore file: /root/topnetwork/keystore/T80000968927100f3cb7b23e8d477298311648978d8613
Account Address: T80000968927100f3cb7b23e8d477298311648978d8613
Private-Key: b0032f8057051b611a7c0ea373da4d7a6764351030ed497e6134fd9e11775b19
{
"account_address" : "T80000968927100f3cb7b23e8d477298311648978d8613",
"address" : "968927100f3cb7b23e8d477298311648978d8613",
"crypto" : {
"cipher" : "aes-128-ctr",
"cipherparams" : {
"iv" : "e40a554c807b913c6e882e933ee6c103"
},
"ciphertext" : "762381ac2219511c647d27424761e81fecc14170eeff6e20412d6c9311149060",
"kdf" : "scrypt",
"kdfparams" : {
"dklen" : 32,
"n" : 262144,
"p" : 1,
"r" : 8,
"salt" : "69c473d9a1ae16ad7cbab057101ccb9632d4109bf7f44e7ff2eba59e269f9932"
},
"mac" : "7d3c31b6aa3f43885682259e6e632b44799700cc7030bdbc1dddb2f587066dac"
},
"hint" : "",
"id" : "b2951865-c391-9d98-ff85-83e149f88990",
"key_type" : "owner",
"public_key" : "BK2CfxnSP0cL9/dbi6b3krWUlQP1jP4EIHu5Y5c2vMBNLMYMOE8K3mqOubDPQXBXc/D4ydtR0LDyWUEyxHO/ZZU=",
"version" : 3
}