UNPKG

postchain-client

Version:

Client library for accessing a Postchain node through REST.

49 lines (48 loc) 2.34 kB
/// <reference types="node" /> import { GTX, RawGtx, RawGtxBody } from "./types"; import { RawGtv } from "../gtv/types"; import { BufferId, SignatureProvider } from "../blockchainClient/types"; export declare function emptyGtx(blockchainRid: Buffer): GTX; /** * Adds a function call to a GTX. Creates a new GTX if none specified. * This function will throw Error if gtx is already signed * @param opName the name of the function to call * @param args the array of arguments of the function call. If no args, this must be an empty array * @param gtx the function call will be added to this gtx * @returns the gtx * @throws if gtx is null or if gtx is already signed */ export declare function addTransactionToGtx(opName: string, args: RawGtv[], gtx: GTX): GTX; export declare function addSignerToGtx(signer: Buffer, gtx: GTX): void; /** * Serializes the gtx to get tx hash * @param gtx the gtx to serialize */ export declare function getDigest(gtx: GTX, merkleHashVersion: number): Buffer; /** * Serializes the gtx for signing * @param gtx the gtx to serialize */ export declare function getDigestToSign(gtx: GTX, merkleHashVersion: number): Buffer; export declare function getDigestToSignFromRawGtxBody(gtxBody: RawGtxBody, merkleHashVersion: number): Buffer; export declare function gtxToRawGtxBody(gtx: GTX): RawGtxBody; export declare function gtxToRawGtx(gtx: GTX): RawGtx; /** * asks the signatureProvider to sign the gtx */ export declare function sign(gtx: GTX, signatureProvider: SignatureProvider, merkleHashVersion: number): Promise<GTX>; export declare function sign(gtx: GTX, privKey: Buffer, merkleHashVersion: number, pubKey?: Buffer): Promise<GTX>; /** * Adds a signature to the gtx */ export declare function addSignature(pubKeyBuffer: Buffer, signatureBuffer: Buffer, gtx: GTX): GTX; export declare function serialize(gtx: GTX): Buffer; export declare function deserialize(gtxBytes: Buffer): GTX; export declare function checkGTXSignatures(txHash: Buffer, gtx: GTX): boolean; export declare function checkExistingGTXSignatures(txHash: Buffer, gtx: GTX): boolean; export declare function newSignatureProvider(merkleHashVersion: number, keyPair?: IKeyPair): SignatureProvider; export declare function rawGtvToGtx(gtv: RawGtv): GTX; export interface IKeyPair { privKey: BufferId; pubKey?: BufferId; }