add binary tx hash compute

This commit is contained in:
Wietse Wind
2023-10-01 23:39:42 +02:00
parent 938c61691a
commit 32b628155d

View File

@@ -0,0 +1,13 @@
import { HashPrefix } from 'ripple-binary-codec/dist/hash-prefixes.js'
import { sha512Half } from 'ripple-binary-codec/dist/hashes.js'
import { Buffer as BufferPf } from "buffer/index.js";
const computeBinaryTransactionHash = txBlobHex => {
const prefix = HashPrefix.transactionID.toString('hex').toUpperCase()
const input = BufferPf.from(prefix + txBlobHex, 'hex')
return sha512Half(input).toString('hex').toUpperCase()
}
export {
computeBinaryTransactionHash,
}