import bigInt = require("big-integer"); import { Network } from "./types"; import * as constants from "./Constants" import { getEraBytes } from "./EraHelper"; import { getBytesInt } from "./TransactionHelper"; import { compactEncode } from "./Encoder"; export function getPayloadDataBytes(era: number, nonce: bigInt.BigInteger, net: Network, tip: bigInt.BigInteger): Buffer{ let specVersion = net == Network.Testnet ? constants.SPECVERSION_TEST : constants.SPECVERSION_MAIN; let specBytes = getBytesInt(specVersion).reverse(); let txVersion = net == Network.Testnet ? constants.TXVERSION_TEST : constants.TXVERSION_MAIN; let txVersionBytes = getBytesInt(txVersion).reverse(); let genesisHash = net == Network.Testnet ? constants.GENESIS_TEST : constants.GENESIS_MAIN; return Buffer.concat([ getEraBytes(era), //Add mortality compactEncode(nonce), //Add nonce compactEncode(tip), //Add chargeTransactionPayment specBytes, //Add specVersion txVersionBytes, //Add txVersion genesisHash, //Add genesisHash genesisHash //If inmortal add genesisHash else add startEraHash ]) }