import { getBytesLong } from "./TransactionHelper"; import { Operation, OperationType } from "./types"; import * as constants from "./Constants" export function getOperationBytes(operation: Operation): Buffer{ let buffer = Buffer.concat([ Buffer.from([0,0,0,operation.type]), //Add operation type constants.PUBKEY_ED25519, //Add publicKeyType (always Ed25519) operation.destinationPubK //Add recipient public key ]) if(operation.type == OperationType.Payment){ //Add asset type (XLM = 0) buffer = Buffer.concat([buffer, constants.ASSET_TYPE_XLM]); } //Add amount let amountBytes = getBytesLong(operation.amountTx); buffer = Buffer.concat([buffer, amountBytes]); return buffer; }