UNPKG

navio-blsct

Version:

TypeScript bindings for the `libblsct` library used by the [Navio](https://nav.io/) blockchain to construct confidential transactions based on the BLS12-381 curve.

74 lines (59 loc) 1.37 kB
import { TxOutputType, } from '../blsct' import { PublicKey } from '../keys/publicKey' import { SubAddr } from '../subAddr' import { SubAddrId } from '../subAddrId' import { TokenId } from '../tokenId' import { TxOut } from '../txOut' import { ViewKey } from '../keys/childKeyDesc/txKeyDesc/viewKey' const genTxOut = (): TxOut => { const vk = ViewKey.random() const spendingPk = PublicKey.random() const subAddrId = SubAddrId.generate(1, 2) const subAddr = SubAddr.generate(vk, spendingPk, subAddrId) const tokenId = TokenId.default() const outputType = TxOutputType.Normal return TxOut.generate( subAddr, 12345, 'navio', tokenId, outputType, 0, ) } test('generate', () => { genTxOut() }) test('getDestination', () => { const x = genTxOut() x.getDestination() }) test('getAmount', () => { const x = genTxOut() x.getAmount() }) test('getMemo', () => { const x = genTxOut() x.getMemo() }) test('getTokenId', () => { const x = genTxOut() x.getTokenId() }) test('getOutputType', () => { const x = genTxOut() x.getOutputType() }) test('getMinStake', () => { const x = genTxOut() x.getMinStake() }) test('serialize and deserialize', () => { const a = genTxOut() const a_hex = a.serialize() const b = TxOut.deserialize(a_hex) const b_hex = b.serialize() expect(a_hex).toBe(b_hex) })