ecash-lib
Version:
Library for eCash transaction building
37 lines • 1.69 kB
TypeScript
/**
* Convert an OP_RETURN outputScript into an array of pushes
* @param outputScript - An OP_RETURN output script, e.g. 6a042e7865630003333333150076458db0ed96fe9863fc1ccec9fa2cfab884b0f6
* @returns An array of hex pushes, e.g. ['2e786563', '00', '333333', '0076458db0ed96fe9863fc1ccec9fa2cfab884b0f6']
* @throws Error if outputScript is not a valid OP_RETURN outputScript
*/
export declare function getStackArray(outputScript: string): string[];
/**
* Swap endianness of a hex string
* @param hexString a string of hex bytes, e.g. 04000000
* @returns a string of hex bytes with swapped endianness, e.g. for 04000000, returns 00000004
*/
export declare function swapEndianness(hexString: string): string;
/**
* Consume a specified number of bytes from a stack object
* @param stack an object containing a hex string outputScript of an eCash tx, e.g. {remainingHex: '6a...'}
* @param byteCount integer
* @returns consumed, a hex string of byteCount bytes
* The stack object is modified in place so that consumed bytes are removed
*/
export declare function consume(stack: {
remainingHex: string;
}, byteCount: number): string;
/**
* Parse, decode and consume the data push from the top of the stack.
* If the stack does not start with a valid push, it raises an error and the stack is left untouched.
* @param stack an object containing a hex string outputScript of an eCash tx, e.g. {remainingHex: '4d...'}
* @returns {data, pushedWith}
* stack is modified in place so that the push is removed
*/
export declare function consumeNextPush(stack: {
remainingHex: string;
}): {
data: string;
pushedWith: string;
};
//# sourceMappingURL=opreturn.d.ts.map