-
Notifications
You must be signed in to change notification settings - Fork 78
wallet_api
The wallet (cli_wallet) requires a running full node to connect to. Here is an example using an HTTP client such as curl for API's
get_account:
$ curl --data '{"jsonrpc": "2.0", "method": "get_account", "params": ["1.2.0"], "id": 2}' http://127.0.0.1:8091/rpc
response:
{"id":2,"jsonrpc":"2.0","result":{"id":"1.2.0","membership_expiration_date":"1969-12-31T23:59:59","merchant_expiration_date":"1970-01-01T00:00:00","datasource_expiration_date":"1970-01-01T00:00:00","data_transaction_member_expiration_date":"1970-01-01T00:00:00","registrar":"1.2.0","referrer":"1.2.0","lifetime_referrer":"1.2.0","merchant_auth_referrer":"1.2.0","datasource_auth_referrer":"1.2.0","network_fee_percentage":2000,"lifetime_referrer_fee_percentage":8000,"referrer_rewards_percentage":0,"name":"committee-account","owner":{"weight_threshold":1,"account_auths":[],"key_auths":[],"address_auths":[]},"active":{"weight_threshold":249866,"account_auths":[["1.2.6",45430],["1.2.7",45430],["1.2.8",45430],["1.2.9",45430],["1.2.10",45430],["1.2.11",45430],["1.2.12",45430],["1.2.13",45430],["1.2.14",45430],["1.2.15",45430],["1.2.16",45430]],"key_auths":[],"address_auths":[]},"options":{"memo_key":"GXC1111111111111111111111111111111114T1Anm","voting_account":"1.2.5","num_witness":0,"num_committee":0,"votes":[],"extensions":[]},"statistics":"2.6.0","whitelisting_accounts":[],"blacklisting_accounts":[],"whitelisted_accounts":[],"blacklisted_accounts":[],"owner_special_authority":[0,{}],"active_special_authority":[0,{}],"top_n_control_flags":0}}
get_block:
$ curl --data '{"jsonrpc": "2.0", "method": "get_block", "params": ["1734131"], "id": 3}' http://127.0.0.1:8091/rpc
response:
{"id":3,"jsonrpc":"2.0","result":{"previous":"001a75f263b534ed126b1578229dbaf5951d90b5","timestamp":"2017-08-16T18:07:49","witness":"1.6.6","transaction_merkle_root":"0000000000000000000000000000000000000000","extensions":[],"witness_signature":"1f2db6deb4c8b7ca9c90e8eafa48af9eb643022ffd43d835ac6d96ee6480d03faf439693c58c501a14142296fbf2743b45f74c8aa0e3f9c3d1b14119428860b32a","transactions":[],"block_id":"001a75f3fe4fc95b7bde117cb34fe3924d9c3183","signing_key":"GXC6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV","transaction_ids":[]}}
get_account_history_by_operations:
# unlock wallet first
$ curl --data '{"jsonrpc": "2.0", "method": "unlock", "params": ["my_password"], "id": 1}' http://127.0.0.1:8091/rpc
{"id":1,"jsonrpc":"2.0","result":null}
$ curl --data '{"jsonrpc": "2.0", "method": "get_account_history_by_operations", "params": ["1.2.17", [0,1], 1, 5], "id": 2}' http://127.0.0.1:8091/rpc
{"id":2,"jsonrpc":"2.0","result":{"total_without_operations":5,"details":[{"memo":"第1笔钱","description":"Transfer 500000 GXC from nathan to init0 -- Memo: 第1笔钱 (Fee: 1.89843 GXC)","op":{"id":"1.11.4","op":[0,{"fee":{"amount":189843,"asset_id":"1.3.0"},"from":"1.2.17","to":"1.2.6","amount":{"amount":"50000000000","asset_id":"1.3.0"},"memo":{"from":"GXC6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV","to":"GXC6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV","nonce":"18376185717943059995","message":"99eaca65bd6deb3148a52b5b4587b303"},"extensions":[]}],"result":[0,{}],"block_num":42,"trx_in_block":1,"op_in_trx":0,"virtual_op":49},"transaction_id":"2bcdb1e2bf48d2f31a769b5e0b70842df9dbb384"},{"memo":"第1笔钱","description":"Transfer 1000000 GXC from nathan to test456 -- Memo: 第1笔钱 (Fee: 1.89843 GXC)","op":{"id":"1.11.3","op":[0,{"fee":{"amount":189843,"asset_id":"1.3.0"},"from":"1.2.17","to":"1.2.18","amount":{"amount":"100000000000","asset_id":"1.3.0"},"memo":{"from":"GXC6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV","to":"GXC6ikt5hsnX8bMGAmJnKmcJ8Cha952GBHnQeyCDhP57yJipvbLyQ","nonce":"7279316236102149689","message":"76ca6d7119b996959cd83b7ea4eb7d29"},"extensions":[]}],"result":[0,{}],"block_num":42,"trx_in_block":0,"op_in_trx":0,"virtual_op":48},"transaction_id":"83ec572e88999ca8f183cd4e8e54726822f640f1"}]}}
$ curl --data '{"jsonrpc": "2.0", "method": "get_account_history_by_operations", "params": ["1.2.17", [0,1], 6, 5], "id": 2}' http://127.0.0.1:8091/rpc
Sets a new password on the wallet. The wallet must be either ‘new’ or ‘unlocked’ to execute this command.
parameters | explanations |
---|---|
new_password | a new password on the wallet |
unlocked >>> set_password my_new_password
null
Unlocks the wallet. The wallet remain unlocked until the lock is called or the program exits.
parameters | explanations |
---|---|
my_password | the password previously set with set_password |
locked >>> unlock my_password
null
unlocked >>>
Imports the private key for an existing account. The private key must match either an owner key or an active key for the named account.
parameters | explanations |
---|---|
account_name_or_id | the account owning the key |
wif_private_key | the private key in WIF format |
true | default true |
Dumps all private keys owned by the wallet. The keys are printed in WIF format. You can import these keys into another wallet using import_key()
Returns information about the given account.
parameters | explanations |
---|---|
account_name_or_id | the name or id of the account to provide information about |
List the balances of an account. Each account can have multiple balances, one for each type of asset owned by that account. The returned list will only contain assets for which the account has a nonzero balance
parameters | explanations |
---|---|
account_name_or_id | the name or id of the account whose balances you want |
Returns the most recent operations on the named account. This returns a list of operation history objects, which describe activity on the account.
parameters | explanations |
---|---|
account_name_or_id | the name or id of the account |
limit_num | the number of entries to return (starting from the most recent) |
Returns the most recent operations on the named account. txID will be included in returned transactions.
parameters | explanations |
---|---|
account_name_or_id | the name or id of the account |
[operations] | operation ids, for example, [0] stands for transfer operation |
start | start sequnence num, 1 stands for the earliest operation |
limit_num | the number of entries to return(starting from start) |
Transfer an amount from one account to another.
parameters | explanations |
---|---|
from_account | the name or id of the account sending the funds |
to_account | the name or id of the account receiving the funds |
amount | the amount to send |
GXS | the symbol or id of the asset to send, GXS stands for GxShares |
memo | a memo to attach to the transaction |
true | true to broadcast the transaction on the network |
This method works just like transfer, except it always broadcasts and returns the transaction ID along with the signed transaction.
parameters | explanations |
---|---|
from_account | the name or id of the account sending the funds |
to_account | the name or id of the account receiving the funds |
amount | the amount to send |
GXS | the symbol or id of the asset to send, GXS stands for GxShares |
memo | a memo to attach to the transaction |
true | true to broadcast the transaction on the network |
Retrieve a full, signed block.
parameters | explanations |
---|---|
block_num | Height of the block to be returned |
Returns info such as client version, git version of graphene/fc, version of boost, openssl.
Returns a list of all commands supported by the wallet API.
Returns detailed help on a single API command.
parameters | explanations |
---|---|
command | the name of the API command you want help with |