Skip to content

Make process transaction able to sign transaction offline (without getting chain_id from node via get_config api call)

Mateusz Żebrak requested to merge mzebrak/process-transaction into develop

I've tested it with the following steps:

  1. Run testnet_node.py
  2. clive process transfer --to "bob" --amount "1 HIVE" --no-broadcast --save-file trx_unsigned.json
  3. cat trx_unsigned.json
{"ref_block_num": 174, "ref_block_prefix": 3871287508, "expiration": "2023-11-27T14:21:18", "extensions": [], "signatures": [], "operations": [{"type": "transfer_operation", "value": {"from": "alice", "to": "bob", "amount": {"amount": "1000", "precision": 3, "nai": "@@000000021"}, "memo": ""}}]}
  1. clive configure node set --node-address http://not.existing:8090

  2. clive show balances

    Error, as expected

  3. clive process transaction --from-file trx_unsigned.json --save-file trx_signed.json --sign alice_key --password alice --no-broadcast --chain-id 18dcf0a285365fc58b71f18b3d3fec954aa0c141c44e4e5cb4cf777b9eab274e

  4. cat trx_signed.json

{"ref_block_num": 174, "ref_block_prefix": 3871287508, "expiration": "2023-11-27T14:21:18", "extensions": [], "signatures": ["1f25bccf058a954a4aa6f1109ee434e53a8276dbc0992778ca8a802ca1a19abfb4361b8801e832aa74a8a68fcd3766abc546727fba4154ec4c6b55366f2b01bd62"], "operations": [{"type": "transfer_operation", "value": {"from": "alice", "to": "bob", "amount": {"amount": "1000", "precision": 3, "nai": "@@000000021"}, "memo": ""}}]}
  1. clive configure node set --node-address http://localhost:8090
  2. clive process transaction --from-file trx_signed.json
Launching beekeeper...
Loaded transaction:
{
  "ref_block_num": 174,
  "ref_block_prefix": 3871287508,
  "expiration": "2023-11-27T14:21:18",
  "extensions": [],
  "signatures": [
    "1f25bccf058a954a4aa6f1109ee434e53a8276dbc0992778ca8a802ca1a19abfb4361b8801e832aa74a8a68fcd3766abc546727fba4154ec4c6b55366f2b01bd62"
  ],
  "operations": [
    {
      "type": "transfer_operation",
      "value": {
        "from": "alice",
        "to": "bob",
        "amount": {
          "amount": "1000",
          "precision": 3,
          "nai": "@@000000021"
        },
        "memo": ""
      }
    }
  ],
  "transaction_id": "364010e774c77f97306eaeeae2e655cf3672c335"
}
Transaction was successfully broadcasted.
  1. clive show balances

Actually shows balance reduced by 1 HIVE

Edited by Mateusz Żebrak

Merge request reports