postchain-client
Version:
Client library for accessing a Postchain node through REST.
46 lines (45 loc) • 2.18 kB
TypeScript
/// <reference types="node" />
import { GTX, RawGtx, RawGtxBody } from "./types";
import { RawGtv } from "../gtv/types";
import { IKeyPair, SignatureProvider } from "./interfaces";
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): Buffer;
/**
* Serializes the gtx for signing
* @param gtx the gtx to serialize
*/
export declare function getDigestToSign(gtx: GTX): Buffer;
export declare function getDigestToSignFromRawGtxBody(gtxBody: RawGtxBody): 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): Promise<GTX>;
export declare function sign(gtx: GTX, privKey: Buffer, pubKey?: Buffer): Promise<GTX>;
export declare function signRawTransaction(_keyPair: Buffer, _rawTransaction: Buffer): void;
/**
* 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(keyPair?: IKeyPair): SignatureProvider;
export declare function rawGtvToGtx(gtv: RawGtv): GTX;