-
Notifications
You must be signed in to change notification settings - Fork 13
BaerChain OnlineWalletUse
- 2.1 Request sign_transaction data
- 2.2 Instruction example
- 2.3 Request parameter description
- 2.4 Interface response
- 2.5 Response description
- 3.1 Request sign_transaction_send data
- 3.2 Instruction example
- 3.3 Request parameter description
- 3.4 Interface response
- 3.5 Return parameter description
1. Online wallet compile and start Back Dir
-
1.1 Compile the project
-
Execute the following command in the cpp-lsac / build directory: cmake .. && make to compile, if you have already executed the cmake .. command, you only need to execute: make command
-
In the directory cpp-lsac/build/wallet/http_wallet, find and find: httpWallet executable program, start operation
-
Remarks: The API calls the KeyPair :: create () interface, and then obtains a random number by calling std :: random_device, and generates a public and private key pair, which is only allowed for Linux before; under a specific version of a specific platform, the random number entropy obtained by std :: random_device If the value is insufficient, the private key is in danger of being predicted.
-
-
View help:
./httpWallet -h
- Parameter Description
command line :
-h [ --help ] show help message.
-p [ --port ] arg http listen port.
-s [ --send ] arg get the http ip and port, use this option will auto to send rawTransation to http host...
--port Online wallet http monitoring port. The default value is 8088.
--send [Optional] After signing the transaction, the wallet sends the transaction to the chain where the address is changed. If there is no such parameter, the parameter signature transaction will not be issued
1.2 Launch online wallet Back to Contents
./httpWallet -p 8081 -s http://127.0.0.1:8111
After starting, the program waits for http request
2 Use online wallet sign_transaction Back Dir
- This instruction is only signed and not chained
- request
- Transaction signature returns transaction hash and transaction signature data, if there is an error this returns a response error prompt
{
"jsonrpc": "2.0",
"id": 1,
"method": "sign_transaction",
"params": {
"param": {
"source": [{
"from": "cccc7a30bf688c060524dfd759fe2627ed3387bc",
"to": "0x00000000000000000000000000000000766f7465",
"value": "0x0",
"data": [{
"type": 2,
"m_from": "cccc7a30bf688c060524dfd759fe2627ed3387bc",
"m_to": "d0e89b32875f5a1d68ecbfb3995263adc3439bea",
"m_transcation_type": 1,
"m_transcation_numbers": "0x5f5e100"
}],
"chainId": "0x1",
"nonce": "0x18",
"gas": "0x138080",
"gasPrice": "0x5"
}],
"keys": ["AupMRj8bvnTwL5No6aE2LKR8hEa2KUZqGwrYMJAXSYuc"]
}
}
}
2.2 Instruction example Back Dir
curl -d '{"jsonrpc":"2.0","id":1,"method":"sign_transaction","params":{ "param":{"source":[{"from":"cccc7a30bf688c060524dfd759fe2627ed3387bc","to":"0x00000000000000000000000000000000766f7465","value":"0x0","data":[{"type":2,"m_from":"cccc7a30bf688c060524dfd759fe2627ed3387bc","m_to":"d0e89b32875f5a1d68ecbfb3995263adc3439bea","m_transcation_type":1,"m_transcation_numbers":"0x5f5e100"}],"chainId":"0x1","nonce":"0x18","gas":"0x138080","gasPrice":"0x5"}],"keys":["AupMRj8bvnTwL5No6aE2LKR8hEa2KUZqGwrYMJAXSYuc"]}}}' http://127.0.0.1:8111
Remarks: Note that you need to add '' to the outermost {} curly bracket, please check the specific use of the instruction
2.3 Request parameter description Back Dir
The request is in jsonrpc standard format, in which:
- method Interface name sign_transaction
- params Transaction json data, used here is: Transfer transaction(Transfer Transcation)Detailed data description can be viewed, If you want to execute other transactions, you can use other: Vote Transaction,PendingOrder Transcation
2.4 Interface response Back Dir
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"hash": "0x581d17a13b5662846947e2bfcaa080cd1cb3a595df287f5db4b44920c76b04bf",
"isSend": false,
"rlp": "0xf8941805831380809400000000000000000000000000000000766f746580b4f3b2f10294cccc7a30bf688c060524dfd759fe2627ed3387bc94d0e89b32875f5a1d68ecbfb3995263adc3439bea01843b9aca0026a043725f6ba923e56e3651e4ed1ee53b7f2b7a32a653b3b6a749567a48a7df0f5da03c9041274bb23f636b9f8502825e9ea277f037afec3948ce269c4b1316263417"
}
}
2.5 Response description Back Dir
The response result is in standard jsonrpc format. The interface call result is in the field "result"
-
(1). Interface call succeeded
- hash : Transaction hash
- rlp : Transaction rlp data
- isSend : Whether to send to the chain, return false by default, this interface implements data signature, but does not go to the chain
-
(2). Interface call failed
- Interface method name error
{
"error": {
"code": -32601,
"message": "METHOD_NOT_FOUND: The method being requested is not available on this server"
},
"id": 1,
"jsonrpc": "2.0"
}
- (3). Interface parameter error
{
"error": {
"code": -32602,
"message": "INVALID_PARAMS: Invalid method parameters (invalid name and/or type) recognised"
},
"id": 1,
"jsonrpc": "2.0"
}
- (4) Transaction json data error
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"error": "the data_json is error"
}
}
3. Sign transaction and send (sign_transaction_send) Back Dir
- This instruction is signed and chained
- 3.1 Request sign_transaction_send data
{
"jsonrpc": "2.0",
"id": 1,
"method": "sign_transaction_send",
"params": {
"param": {
"source": [{
"from": "cccc7a30bf688c060524dfd759fe2627ed3387bc",
"to": "0x00000000000000000000000000000000766f7465",
"value": "0",
"data": [{
"type": 2,
"m_from": "cccc7a30bf688c060524dfd759fe2627ed3387bc",
"m_to": "d0e89b32875f5a1d68ecbfb3995263adc3439bea",
"m_transcation_type": 1,
"m_transcation_numbers": "0x5f5e100"
}],
"chainId": "0x1",
"nonce": "0x0",
"gas": "0x138080",
"gasPrice": "0x5"
}],
"keys": ["AupMRj8bvnTwL5No6aE2LKR8hEa2KUZqGwrYMJAXSYuc"]
}
}
}
- 3.2 Instruction example Back Dir
curl -d '{"jsonrpc":"2.0","id":1,"method":"sign_transaction_send","params":{ "param":{"source":[{"from":"cccc7a30bf688c060524dfd759fe2627ed3387bc","to":"0x00000000000000000000000000000000766f7465","value":"0","data":[{"type":2,"m_from":"cccc7a30bf688c060524dfd759fe2627ed3387bc","m_to":"d0e89b32875f5a1d68ecbfb3995263adc3439bea","m_transcation_type":1,"m_transcation_numbers":"0x5f5e100"}],"chainId":"0x1","nonce":"0x0","gas":"0x138080","gasPrice":"0x5"}],"keys":["AupMRj8bvnTwL5No6aE2LKR8hEa2KUZqGwrYMJAXSYuc"]}}}' http://127.0.0.1:8111
Remarks: Note that you need to add '' to the outermost {} curly bracket, please check the specific use of the instruction
- 3.3 Request parameter description Back Dir
- The request is in jsonrpc standard format, in which:
- method Interface name sign_transaction_send
- params Transaction json This use: Transfer transaction(Transfer Transcation)You can view the detailed data description, if you want to execute other transactions, you can use other: Vote Transaction,PendingOrder Transcation
- 3.4 Interface response Back Dir
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"hash": "0x1bf48beac1498752d0b90466e6c237887c7f4caa20a91714b935ae174806f8d1",
"rlp": "0xf8968005831380809400000000000000000000000000000000766f7465820100b4f3b2f10294cccc7a30bf688c060524dfd759fe2627ed3387bc94d0e89b32875f5a1d68ecbfb3995263adc3439bea01843b9aca0025a077abdfc6f0b4730fc1b5833dae5ed145732c9b45b96116960629463145c33feea01415dcff697067ca59bbd0ce65b29266d8da027bcb1829d627d17e816da66cbe",
"sendRet": {
"id": 1,
"jsonrpc": "2.0",
"result": "0x1bf48beac1498752d0b90466e6c237887c7f4caa20a91714b935ae174806f8d1"
}
}
}
-
3.5 Return parameter description Back Dir
-
(1). Interface call succeeded
- hash : transaction hsah
- rlp : Transaction rlp data
- sendRet : Return value of successful transaction(transaction hash)
-
(2). Interface call failed
-
Interface method name error : Same as sign_transaction interface failure
-
Interface parameter error : Same as sign_transaction interface failure
-
Transaction json data error : Same as sign_transaction interface failure
-
The signature is successful and the transmission is successful but the transaction fails (transaction nonce error), The specific error reason is as follows: "error" field returned
{ "id": 1, "jsonrpc": "2.0", "result": { "hash": "0xc65590930708d5d74678cce71a658dabe8b4253512b17ed977797e76299e22a8", "rlp": "0xf8960405831380809400000000000000000000000000000000766f7465820100b4f3b2f10294000000000000000000000000000000000000000094d0e89b32875f5a1d68ecbfb3995263adc3439bea01843b9aca0025a01d2c3bd9f4e6b51fa1d48427905e84d18740d9b85a0ccc9245c0ac3d14a53723a010c59dbed79a648781dc09c5dc020d1525abed5682bb880e841291f506952de5", "sendRet": { "error": { "code": 0, "data": null, "message": "Invalid transaction nonce.the sender Nonce error" }, "id": 1, "jsonrpc": "2.0" } } }
-
-
(3) httpWallet Start parameters --send (Parameter error, unable to send transaction to chain)
{ "id": 1, "jsonrpc": "2.0", "result": { "error": "send field check the send_url", "hash": "0xc65590930708d5d74678cce71a658dabe8b4253512b17ed977797e76299e22a8", "rlp": "0xf8960405831380809400000000000000000000000000000000766f7465820100b4f3b2f10294000000000000000000000000000000000000000094d0e89b32875f5a1d68ecbfb3995263adc3439bea01843b9aca0025a01d2c3bd9f4e6b51fa1d48427905e84d18740d9b85a0ccc9245c0ac3d14a53723a010c59dbed79a648781dc09c5dc020d1525abed5682bb880e841291f506952de5" } }
4. Apply to generate address and private key(new_address) Back Dir
- request
{"jsonrpc":"2.0","method":"new_address","params":["2"],"id":1}
- 4.1 Instruction example Back Dir
curl -d '{"jsonrpc":"2.0","method":"new_address","params":["2"],"id":1}' http://127.0.0.1:8111
- Parameter Description
method : Method name
params : string, Represents the number of generated addresses, in this case 2
- 4.2 Return result Back Dir
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"result": [{
"address": "6d9b912d847d146ab00eed2d8e23b1846d2567d4",
"pri-key-base58": "4nQVPAddSi67pNGWJwEo4gbuegn7m8ySXEfBVix8exEk",
"pri-key-bigInt": "3834c1b5a0f75c83ac5a4350af437df828da7d4c3e8a36bd3b69b6292fdcbeb1",
"pub-key": "206a7c04c5d5b06481e758fc559556e990944a6bc09690b95cf740c75f8797b684819aa084d09dd5758f0a75628abb773f2b95355a4ab557725289d49375c43f"
},
{
"address": "8a9f0ccae769f1b83858cd04d4ae8b0a988a32c0",
"pri-key-base58": "5idSd8sCeP2nqF4TkTiLSpkSSbQAc95zJeo6V8iopPCF",
"pri-key-bigInt": "4618c40693bd1fb8bedfa66f63bc094cc70aff0db0880174cd8e8690d6726f3c",
"pub-key": "c59504eacb630cad69bda4eac556d4625368205f9886416a023b5145fb4e583fbe49b46fb136ad331111e10062f637613ea935f96c8dbb42181ee267b4ddfba8"
}
]}
}
- Parameter Description
address : Generated address
pri-key-base58 : base58 encoded private key
pri-key-bigInt : bigInt encoded private key
pub-key : Public key