-
Notifications
You must be signed in to change notification settings - Fork 1
1.4 Commander
In order to use the commander, PUBLIQ daemon will need to be run like this
bin/publiq.pp/publiqd -i 0.0.0.0:14000 -r 127.0.0.1:14001 --action_log
Then we can have the commander
bin/publiq.pp/commander -l 0.0.0.0:8080 -c 127.0.0.1:14001 -p PBQ
Great. Now we have the commander RPC API on port 8080. It is both a JSON and an HTTP API, below we describe the HTTP API.
Request http://127.0.0.1:8080/head_block
Response {"rtt":1,"value":851}
An example response shows that the current block index is 851
Request http://127.0.0.1:8080/import/$ACCOUNT_PUBLIC_ADDRESS
Response {"rtt":6}
This example response tells that it was imported successfully.
Here instead of $ACCOUNT_PUBLIC_ADDRESS we use an address which looks like PBQ7Ta31VaxCB9VfDRvYYosKYpzxXNgVH46UkM9i4FhzNg4JEU3YJ
Request http://127.0.0.1:8080/accounts
Response
{"rtt":11,"accounts":[{"rtt":5,"address":"PBQ76Zv5QceNSLibecnMGEKbKo3dVFV6HRuDSuX59mJewJxHPhLwu","balance":{"rtt":3,"whole":103,"fraction":99999970},"confirmed_balance":{"rtt":3,"whole":94,"fraction":99999970},"unconfirmed_sent":{"rtt":3,"whole":0,"fraction":0},"unconfirmed_received":{"rtt":3,"whole":9,"fraction":0}}]}
Request http://127.0.0.1:8080/account/$ACCOUNT_PUBLIC_ADDRESS
Response
{"rtt":5,"address":"PBQ76Zv5QceNSLibecnMGEKbKo3dVFV6HRuDSuX59mJewJxHPhLwu","balance":{"rtt":3,"whole":103,"fraction":99999970},"confirmed_balance":{"rtt":3,"whole":94,"fraction":99999970},"unconfirmed_sent":{"rtt":3,"whole":0,"fraction":0},"unconfirmed_received":{"rtt":3,"whole":9,"fraction":0}}
Request http://127.0.0.1:8080/log/$START_BLOCK_INDEX/$MAX_COUNT_OF_BLOCKS/$ACCOUNT_PUBLIC_ADDRESS
Example http://127.0.0.1:8080/log/2/1/PBQ63qkN2aayZYyqRwa1EwnaEu6w5sSQBifS8pMm6qLtuLL8hStZm
Response
{"rtt":13,"log":[{"rtt":14,"block_index":2,"confirmations":853,"item_type":"received","timestamp":"2019-02-12 12:54:36","amount":{"rtt":3,"whole":100,"fraction":0},"details":{"rtt":15,"from":"PBQ7Ta31VaxCB9VfDRvYYosKYpzxXNgVH46UkM9i4FhzNg4JEU3YJ","message":"","transaction_hash":"DHMREuoXuFecc2qdjXWPuTZTCSwxyNjZUymD5uNDG9vh"}},{"rtt":14,"block_index":2,"confirmations":853,"item_type":"received","timestamp":"2019-02-12 12:54:37","amount":{"rtt":3,"whole":200,"fraction":0},"details":{"rtt":15,"from":"PBQ7Ta31VaxCB9VfDRvYYosKYpzxXNgVH46UkM9i4FhzNg4JEU3YJ","message":"","transaction_hash":"KM1WaMuZa6TUdVDQcYCYUTTgBwigP6fyNfWbRgnS9Yf"}}]}
The transactions that are not yet included in the blockchain have block_index = head_block_index + 1 and confirmations = 0. And block_index + confirmations = head_block_index + 1, always holds true
Request http://127.0.0.1:8080/send/$SENDER_PRIVATE_KEY?to=$RECEIVER_PUBLIC_KEY&whole=1&seconds=1000
Response {"rtt":0,"value":"FvAvkBPHCewDyAy58oqZ7vZgwsn5u3XuVD7WJWsGTSZ4"}
This example response shows the generated transaction hash, which can be tracked in account history, to see if it got included in the blockchain or not.
This request uses the sender account private key, only to sign and broadcast a transaction. Available HTTP request options are following - to, message, whole, fraction, fee_whole, fee_fraction, seconds. Thus we can provide detailed description for the transfer. The argument seconds, defines when the signed transaction becomes invalid. There is a hard-coded upper limit of 24 hours.
The amount of coins is represented as {"rtt":3,"whole":100,"fraction":0}
Both - whole and fraction are integer values. Fraction can only be in range of [0, 100.000.000)
- note that 108 is not included in the range. The arithmetic is based on the definition
1 whole = 10
8 fraction
.
Timestamp is formatted as 2019-02-12 13:54:37
, it means a UTC time.