Need help. How can I get Hash on RawTransactionBytes for transaction sign?

i have txr bytes:

[10, 32, 157, 65, 14, 51, 225, 244, 160, 125, 146, 101, 54, 45, 206, 86, 233, 178, 168, 176, 21, 211, 76, 151, 35, 117, 29, 95, 154, 251, 123, 107, 174, 233, 16, 2, 40, 144, 78, 56, 142, 140, 210, 233, 5, 26, 232, 1, 10, 179, 1, 76, 73, 66, 82, 65, 86, 77, 10, 1, 0, 7, 1, 74, 0, 0, 0, 4, 0, 0, 0, 3, 78, 0, 0, 0, 6, 0, 0, 0, 12, 84, 0, 0, 0, 5, 0, 0, 0, 13, 89, 0, 0, 0, 4, 0, 0, 0, 5, 93, 0, 0, 0, 41, 0, 0, 0, 4, 134, 0, 0, 0, 32, 0, 0, 0, 7, 166, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 1, 3, 0, 2, 0, 2, 4, 2, 3, 2, 4, 2, 6, 60, 83, 69, 76, 70, 62, 12, 76, 105, 98, 114, 97, 65, 99, 99, 111, 117, 110, 116, 4, 109, 97, 105, 110, 15, 112, 97, 121, 95, 102, 114, 111, 109, 95, 115, 101, 110, 100, 101, 114, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 4, 0, 12, 0, 12, 1, 17, 1, 2, 18, 36, 8, 1, 18, 32, 54, 219, 162, 218, 78, 180, 238, 31, 153, 85, 128, 9, 64, 160, 41, 212, 53, 166, 188, 28, 212, 173, 116, 142, 198, 58, 157, 158, 68, 16, 195, 69, 18, 10, 18, 8, 64, 84, 137, 0, 0, 0, 0, 0 ]

Right hash for it: de37ecdf073708e4dce825c1c1706e818a8c6c1ddc4a24f8746a156d76038459

i tried to get Sha3_256, and received: ec9099b61ac78b6c928d2bfc2897c1e992f11777f34fa509c79e03ef6a2ea088

How can I get the right transaction hash?

Libra uses different hasher for different type of object. All hashers are derived from sha3_256.

In your case, you need a RawTransaction hasher, which is defined here: https://github.com/libra/libra/blob/master/crypto/legacy_crypto/src/hash.rs#L516

Or you can have a look at my golang implementation: https://github.com/the729/go-libra/blob/master/crypto/sha3libra/hashes.go

1 Like

Thx a lot, i couldn’t find it LIBRA_HASH_SUFFIX, you really help me

How you put right ExpirationTime for transaction?

An absolute UNIX timestamp, e.g. Now() + 60s

1 Like

Thx, i tried +60, +10, +30 :frowning:
Can’t understand why my transactions are failed… I recieve VmStatus empty arry, and transaction sends to validators and validators dont approve it:
https://libraview.org/Account/9d410e33e1f4a07d9265362dce56e9b2a8b015d34c9723751d5f9afb7b6baee9

Could you check pls using your code if transactions are sending :frowning:

What exactly does the badges “In” and “In Failed” mean? From which RPC response do you get these states of transactions?

Oh, I see. You ran out of gas.

Max Gas Amount is not in microLibra, it is the number of gas units. Currently a P2P txn needs 29925 gas, so max gas amount must be greater than that. However, you can set gas price to 0.

1 Like

Wow, cool !!! Realy works :+1: Thanks :metal:
(I used it, and it works:
ExpirationTime = (ulong)DateTimeOffset.UtcNow.AddSeconds(60).ToUnixTimeSeconds(),
GasUnitPrice = 0,
MaxGasAmount = 29925,
)

How did you calculate this value for MaxGasAmount? (maybe you have some useful links on this topic)

Nothing special. If you set gas unit price to 1, along with a large enough max amount, the total gas used will be 29925.

The official client has max amount set to 100,000.

1 Like