-
Notifications
You must be signed in to change notification settings - Fork 8
cli_wallet API
It is convenient to use cli_wallet instead of witness_node because of absence of access levels ('history' or 'database').
Cli_wallet allows you to use internal (commands via terminal), ws-rpc or REST interfaces.
For example, if your cli_wallet has started with command like this:
user@user:~/blockchain$ ./programs/cli_wallet/cli_wallet --server-rpc-endpoint=ws://127.0.0.1:5909 --rpc-endpoint=127.0.0.1:8085 --chain-id=979b29912e5546dbf47604692aafc94519f486c56221a5705f0c7f5f294df126 --wallet-file=./wallet.json --no-backups
then you can do your http and rpc-ws requests on 8085 port.
But firstly after cli_wallet's starting you must set its password:
new >>> set_password 'any_password'
locked >>> unlock 'password'
Don't lose your wallet.json!
Sample of terminal's command:
unlocked >>> info
Response:
{
"head_block_num": 17281118,
"head_block_id": "0107b05e1d0bfbb035858a1eef6976e39ed2b269",
"head_block_age": "4 seconds old",
"next_maintenance_time": "18 hours in the future",
"chain_id": "979b29912e5546dbf47604692aafc94519f486c56221a5705f0c7f5f294df126",
"participation": "100.00000000000000000",
"active_witnesses": [
"1.6.1",
"1.6.2",
"1.6.3",
"1.6.4",
"1.6.5",
"1.6.6",
"1.6.7",
"1.6.8",
"1.6.9",
"1.6.10",
"1.6.11"
],
"active_committee_members": [
"1.5.0",
"1.5.11",
"1.5.1",
"1.5.2",
"1.5.3",
"1.5.4",
"1.5.5",
"1.5.6",
"1.5.7",
"1.5.8",
"1.5.9",
"1.5.10"
]
}
Sample of ws-rpc-request to cli_wallet:
> {"method":"call","params":[0,"suggest_brain_key",[]],"id":1}
< {"id":1,"result":{"brain_priv_key":"FEAGUE HOLD SCRAPED LYRE BIGGAH PROSAIC MALTHA ADAUNT ALDEHOL KHANKAH RONDE GYRINID VITIUM DIRT ZOOPERY FUNKY","wif_priv_key":"5KkX3Jj4jyEmuebRtHmtCsmK1ZEeu1kAByrZ9EN3ehHSWqaN1Wa","pub_key":"EDC7p3CUWVK3zdgXP7CvuZPibFCTPXtY7HTNHzNhB88Hco5PvoTMf"}}
Sample of POST-request:
curl -XPOST -H "Content-type: application/json" -d '{ "jsonrpc": "2.0", "method": "suggest_brain_key", "params": [], "id": 1 }' 'http://127.0.0.1:8086/rpc'
Response:
{
"id":1,
"result":{"brain_priv_key":"DIVERT DISWOOD SCALDIC BETHUMP BEGULF POPPLY BUGDOM VANITY MANDATE DUPLEX UNHULL RISSLE SINGLET WEEDFUL GALANAS QUOTEE","wif_priv_key":"5JsdQQiS5NzQA5Dez5y1iCsHN8fLaRLeMYePoLr7k1WmHyB2n9v","pub_key":"EDC7FYq2djQA4m8QEs6PRoNg9sm5Nyjj3QjKYcE74EFe6wUDgXoMG"}
}
Examples of the most useful commands:
unlocked >>> transfer test1 test2 1000.000 EDC "here is the cash" true
unlocked >>> list_account_balances test1
From new entities to old:
unlocked >>> get_account_history_part "1.2.837958" "1.11.24378019" 5 "1.11.24417095"
, where 1.2.837958 - account's ID, 5 - limit, 1.11.24378019 - ID of history object.
From old to new:
unlocked >>> get_account_operation_history4 "1.2.837958" "1.11.27453105" 100 [0]
A full list of cli_wallet commands is available (bottom of the page)(https://github.com/EDCBlockchain/blockchain/blob/master/libraries/wallet/include/graphene/wallet/wallet.hpp)