1
0
mirror of https://github.com/bigchaindb/js-bigchaindb-driver.git synced 2024-11-24 11:01:28 +01:00

Merge pull request #1 from robertdavid010/robertdavid010-patch-1

Add support for single and array of private keys
This commit is contained in:
Robert David 2018-08-15 14:19:40 +02:00 committed by GitHub
commit 84dd243912
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -231,12 +231,13 @@ export default class Transaction {
* @returns {Object} The signed version of `transaction`.
*/
static signTransaction(transaction, ...privateKeys) {
privateKeys = Array.isArray(privatekeys[0]) ? privateKeys[0]: privateKeys;
const signedTx = clone(transaction)
const serializedTransaction =
Transaction.serializeTransactionIntoCanonicalString(transaction)
signedTx.inputs.forEach((input, index) => {
const privateKey = privateKeys[index]
const privateKey = privateKeys[index] || privateKeys[0]
const privateKeyBuffer = Buffer.from(base58.decode(privateKey))
const transactionUniqueFulfillment = input.fulfills ? serializedTransaction