From 5993c4cd6b0902afa8d79925ccb72381cfc17d92 Mon Sep 17 00:00:00 2001 From: amed83 Date: Tue, 5 Jun 2018 15:14:15 +0200 Subject: [PATCH] changed forEach method --- src/transaction.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/transaction.js b/src/transaction.js index fc0b75d..6d98451 100644 --- a/src/transaction.js +++ b/src/transaction.js @@ -228,11 +228,12 @@ export default class Transaction { */ static signTransaction(transaction, ...privateKeys) { const signedTx = clone(transaction) + const serializedTransaction = + Transaction.serializeTransactionIntoCanonicalString(transaction) + signedTx.inputs.forEach((input, index) => { const privateKey = privateKeys[index] const privateKeyBuffer = Buffer.from(base58.decode(privateKey)) - const serializedTransaction = - Transaction.serializeTransactionIntoCanonicalString(transaction) const transactionUniqueFulfillment = input.fulfills ? serializedTransaction .concat(input.fulfills.transaction_id) @@ -245,9 +246,9 @@ export default class Transaction { input.fulfillment = fulfillmentUri }) - const serializedTransaction = + const serializedSecondTransaction = Transaction.serializeTransactionIntoCanonicalString(signedTx) - signedTx.id = sha256Hash(serializedTransaction) + signedTx.id = sha256Hash(serializedSecondTransaction) return signedTx } }