Forge, Sign, Inject operation


#1

Hi. Can anybody help me understand workflow for create transaction with stages Forge, Sign and Inject operation? I read this article, but not understanding all stages.

Forge operation

./tezos-client rpc post http://127.0.0.1:8742/chains/main/blocks/head/helpers/forge/operations with '{"branch": "BLpcXF8ADJbGuyUKNv7TypXRd5rqnoPn3PMqJLNBeRSr4VFeUuK","contents":[{"kind":"transaction","source":"tz1NfEiS2uJsX43vowNjau5pdqg3Nvy8whvc","destination":"KT1Ec3jNXyxyA54nezwcjGDRoutECJCQjpya","fee":"1274","counter":"86610","gas_limit": "10100", "storage_limit": "0","amount":"5060726"}]}'

Output: <operation_bytes>

"92122a7e654cdff09e22a7be1b7d41bd279ffa197a0137e6fea0d3ed3ce95fc00800002122d44d997e158c36c60649d198c4175dad425efa09d2a405f44e00f6f0b40201420eaa410ac21addf427211cddd6115cba385a940000"

Sign bytes

./tezos-client sign bytes 0x0392122a7e654cdff09e22a7be1b7d41bd279ffa197a0137e6fea0d3ed3ce95fc00800002122d44d997e158c36c60649d198c4175dad425efa09d2a405f44e00f6f0b40201420eaa410ac21addf427211cddd6115cba385a940000 for tz1NfEiS2uJsX43vowNjau5pdqg3Nvy8whvc

Output

Signature: sigjUx6U8n3vDiegRWSGjRhd24jVHdr2PVk1GvNePDYs8CTEoBcbRVGq2zUWhqveAc1eCSJWqV8pwwSDowfTJpPPcdVUPQw9

I this article (https://medium.com/@bakenrolls/sending-multiple-transactions-in-one-batch-using-tezos-rpc-6cab3a21f254) describes that I should decode signature from Base58 format to hexademical.

I put sigjUx6U8n3vDiegRWSGjRhd24jVHdr2PVk1GvNePDYs8CTEoBcbRVGq2zUWhqveAc1eCSJWqV8pwwSDowfTJpPPcdVUPQw9 to field “Base58 data…” and press “Decode”.
https://incoherency.co.uk/base58/

But I have sig* signature, not edsig When I decode it from Base58 format to hexademical, hex string is 04822babce...8_last_hex_symbols . Not like 09f5cd8612...8_last_hex_symbols .

Ok, I however get 04822babce<decoded_sig_signature>8_last_hex_symbols and try create signed_operation_bytes:

<signed_operation_bytes> = <operation_bytes><decoded_sig_signature>

Inject operation

/opt/tezos-zeronet/bin/tezos-client -l rpc post http://127.0.0.1:8742/injection/operation with <signed_operation_bytes>

run

/opt/tezos-zeronet/bin/tezos-client -l rpc post http://127.0.0.1:8742/injection/operation with '"92122a7e654cdff09e22a7be1b7d41bd279ffa197a0137e6fea0d3ed3ce95fc00800002122d44d997e158c36c60649d198c4175dad425efa09d2a405f44e00f6f0b40201420eaa410ac21addf427211cddd6115cba385a940000bddc0c3d61ca90269d11d1c96cb1e546d5e42c67ef467909783815b9dfd9d0b0162eed936d3d5b80741cc877cb423623a40e74758e6d39779b6830055805"'

Output:

>>>>0: http://localhost:8742/injection/operation
  "92122a7e654cdff09e22a7be1b7d41bd279ffa197a0137e6fea0d3ed3ce95fc00800002122d44d997e158c36c60649d198c4175dad425efa09d2a405f44e00f6f0b40201420eaa410ac21addf427211cddd6115cba385a940000bddc0c3d61ca90269d11d1c96cb1e546d5e42c67ef467909783815b9dfd9d0b0162eed936d3d5b80741cc877cb423623a40e74758e6d39779b6830055805"
Unexpected server answer

Or with curl

curl -X POST http://127.0.0.1:8742/injection/operation -H 'Cache-Control: no-cache'  -H 'Content-Type: application/json' -d '"92122a7e654cdff09e22a7be1b7d41bd279ffa197a0137e6fea0d3ed3ce95fc00800002122d44d997e158c36c60649d198c4175dad425efa09d2a405f44e00f6f0b40201420eaa410ac21addf427211cddd6115cba385a940000bddc0c3d61ca90269d11d1c96cb1e546d5e42c67ef467909783815b9dfd9d0b0162eed936d3d5b80741cc877cb423623a40e74758e6d39779b6830055805"'

Output

[{"kind":"permanent","id":"node.prevalidation.parse_error"}]

Where make mistakes? I didn’t find good description on tezos.gitlab.io/mainnet.


#2

Problem was in that the tezos-signer is producing generic signatures, not edsig signatures.
With sig format needed get first 3 bytes sig, last 4 bytes checksum.