js-bigchaindb-driver/src/transaction/hashTransaction.js

11 lines
382 B
JavaScript
Raw Normal View History

2017-06-12 16:57:29 +02:00
import serializeTransactionIntoCanonicalString from './serializeTransactionIntoCanonicalString'
import sha256Hash from '../sha256Hash'
2017-04-26 15:58:19 +02:00
export default function hashTransaction(transaction) {
// Safely remove any tx id from the given transaction for hashing
2017-06-12 16:57:29 +02:00
const tx = { ...transaction }
delete tx.id
2017-04-26 15:58:19 +02:00
2017-06-12 16:57:29 +02:00
return sha256Hash(serializeTransactionIntoCanonicalString(tx))
}