mirror of
https://github.com/Xahau/Validation-Ledger-Tx-Store-to-xPOP.git
synced 2025-11-13 16:35:49 +00:00
add binary tx hash compute
This commit is contained in:
13
lib/computeBinaryTransactionHash.mjs
Normal file
13
lib/computeBinaryTransactionHash.mjs
Normal 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,
|
||||
}
|
||||
Reference in New Issue
Block a user