UNPKG

@ledgerhq/coin-algorand

Version:
20 lines 908 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.combine = combine; const algosdk_1 = require("algosdk"); const ED25519_SIGNATURE_LENGTH = 64; /** * Combine an unsigned transaction with a signature * @param unsignedTx - The unsigned transaction as a hex string (msgpack encoded) * @param signature - The signature as a hex string * @returns The signed transaction as a hex string */ function combine(unsignedTx, signature) { const txBytes = Buffer.from(unsignedTx, "hex"); const txn = (0, algosdk_1.decodeUnsignedTransaction)(txBytes); const sig = Buffer.from(signature, "hex").subarray(0, ED25519_SIGNATURE_LENGTH); const signedPayload = new algosdk_1.SignedTransaction({ sig, txn }); const msgPackEncoded = (0, algosdk_1.encodeMsgpack)(signedPayload); return Buffer.from(msgPackEncoded).toString("hex"); } //# sourceMappingURL=combine.js.map