Browse Source

Catch up with fixtureTypes

addTSTests
junderw 6 years ago
parent
commit
f16e9338b3
No known key found for this signature in database GPG Key ID: B256185D3A971908
  1. 1
      test/block.js
  2. 7
      test/ecpair.js
  3. 16
      test/transaction_builder.js
  4. 1
      ts_src/index.ts
  5. 1
      ts_test/block.ts
  6. 7
      ts_test/crypto.ts
  7. 25
      ts_test/ecpair.ts
  8. 153
      ts_test/fixtureTypes.ts
  9. 7
      ts_test/script.ts
  10. 3
      ts_test/script_number.ts
  11. 7
      ts_test/script_signature.ts
  12. 68
      ts_test/transaction_builder.ts
  13. 1
      types/index.d.ts

1
test/block.js

@ -55,6 +55,7 @@ describe('Block', () => {
});
it('exports ' + f.description, () => {
assert.strictEqual(block.toHex(true), f.hex.slice(0, 160));
// @ts-ignore
assert.strictEqual(block.toHex(), f.hex);
});
});

7
test/ecpair.js

@ -24,10 +24,13 @@ describe('ECPair', () => {
keyPair = __1.ECPair.fromPrivateKey(ONE);
});
it('calls pointFromScalar lazily', hoodwink(() => {
// @ts-ignore
assert.strictEqual(keyPair.__Q, undefined);
// .publicKey forces the memoization
assert.strictEqual(keyPair.publicKey.toString('hex'), '0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798');
assert.strictEqual(keyPair.__Q.toString('hex'), '0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798');
assert.strictEqual(
// @ts-ignore
keyPair.__Q.toString('hex'), '0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798');
}));
});
describe('fromPrivateKey', () => {
@ -61,6 +64,7 @@ describe('ECPair', () => {
it('throws ' + f.exception, () => {
const d = Buffer.from(f.d, 'hex');
assert.throws(() => {
// @ts-ignore
__1.ECPair.fromPrivateKey(d, f.options);
}, new RegExp(f.exception));
});
@ -203,6 +207,7 @@ describe('ECPair', () => {
assert.strictEqual(keyPair.sign(hash), signature);
}));
it('throws if no private key is found', () => {
// @ts-ignore
delete keyPair.__D;
assert.throws(() => {
keyPair.sign(hash);

16
test/transaction_builder.js

@ -42,7 +42,7 @@ function construct(f, dontSign) {
txb.setVersion(f.version);
if (f.locktime !== undefined)
txb.setLockTime(f.locktime);
f.inputs.forEach(input => {
f.inputs.forEach((input) => {
let prevTx;
if (input.txRaw) {
const constructed = construct(input.txRaw);
@ -63,7 +63,7 @@ function construct(f, dontSign) {
}
txb.addInput(prevTx, input.vout, input.sequence, prevTxScript);
});
f.outputs.forEach(output => {
f.outputs.forEach((output) => {
if (output.address) {
txb.addOutput(output.address, output.value);
}
@ -137,7 +137,7 @@ describe('TransactionBuilder', () => {
const tx = __1.Transaction.fromHex(fixtures.valid.classification.hex);
const txb = __1.TransactionBuilder.fromTransaction(tx);
// @ts-ignore
txb.__INPUTS.forEach(i => {
txb.__INPUTS.forEach((i) => {
assert.strictEqual(i.prevOutType, 'scripthash');
assert.strictEqual(i.redeemScriptType, 'multisig');
});
@ -159,19 +159,23 @@ describe('TransactionBuilder', () => {
it('accepts a txHash, index [and sequence number]', () => {
const vin = txb.addInput(txHash, 1, 54);
assert.strictEqual(vin, 0);
// @ts-ignore
const txIn = txb.__TX.ins[0];
assert.strictEqual(txIn.hash, txHash);
assert.strictEqual(txIn.index, 1);
assert.strictEqual(txIn.sequence, 54);
// @ts-ignore
assert.strictEqual(txb.__INPUTS[0].prevOutScript, undefined);
});
it('accepts a txHash, index [, sequence number and scriptPubKey]', () => {
const vin = txb.addInput(txHash, 1, 54, scripts[1]);
assert.strictEqual(vin, 0);
// @ts-ignore
const txIn = txb.__TX.ins[0];
assert.strictEqual(txIn.hash, txHash);
assert.strictEqual(txIn.index, 1);
assert.strictEqual(txIn.sequence, 54);
// @ts-ignore
assert.strictEqual(txb.__INPUTS[0].prevOutScript, scripts[1]);
});
it('accepts a prevTx, index [and sequence number]', () => {
@ -180,10 +184,12 @@ describe('TransactionBuilder', () => {
prevTx.addOutput(scripts[1], 1);
const vin = txb.addInput(prevTx, 1, 54);
assert.strictEqual(vin, 0);
// @ts-ignore
const txIn = txb.__TX.ins[0];
assert.deepStrictEqual(txIn.hash, prevTx.getHash());
assert.strictEqual(txIn.index, 1);
assert.strictEqual(txIn.sequence, 54);
// @ts-ignore
assert.strictEqual(txb.__INPUTS[0].prevOutScript, scripts[1]);
});
it('returns the input index', () => {
@ -208,6 +214,7 @@ describe('TransactionBuilder', () => {
const { address } = __1.payments.p2pkh({ pubkey: keyPair.publicKey });
const vout = txb.addOutput(address, 1000);
assert.strictEqual(vout, 0);
// @ts-ignore
const txout = txb.__TX.outs[0];
assert.deepStrictEqual(txout.script, scripts[0]);
assert.strictEqual(txout.value, 1000);
@ -215,6 +222,7 @@ describe('TransactionBuilder', () => {
it('accepts a ScriptPubKey and value', () => {
const vout = txb.addOutput(scripts[0], 1000);
assert.strictEqual(vout, 0);
// @ts-ignore
const txout = txb.__TX.outs[0];
assert.deepStrictEqual(txout.script, scripts[0]);
assert.strictEqual(txout.value, 1000);
@ -276,7 +284,7 @@ describe('TransactionBuilder', () => {
return Buffer.alloc(32, 1);
},
}).publicKey,
sign: (hash) => {
sign: () => {
return Buffer.alloc(64, 0x5f);
},
};

1
ts_src/index.ts

@ -14,6 +14,7 @@ export { Transaction } from './transaction';
export { TransactionBuilder } from './transaction_builder';
export { BIP32Interface } from 'bip32';
export { ECPairInterface } from './ecpair';
export { Network } from './networks';
export { Payment, PaymentOpts } from './payments';
export { OpCode } from './script';

1
ts_test/block.ts

@ -71,6 +71,7 @@ describe('Block', () => {
it('exports ' + f.description, () => {
assert.strictEqual(block.toHex(true), f.hex.slice(0, 160));
// @ts-ignore
assert.strictEqual(block.toHex(), f.hex);
});
});

7
ts_test/crypto.ts

@ -1,15 +1,16 @@
import { crypto as bcrypto } from '..';
import { FixtureCrypto } from './fixtureTypes';
const { describe, it } = require('mocha');
const assert = require('assert');
const fixtures = require('../ts_test/fixtures/crypto');
const fixtures: FixtureCrypto = require('../ts_test/fixtures/crypto');
describe('crypto', () => {
['hash160', 'hash256', 'ripemd160', 'sha1', 'sha256'].forEach(algorithm => {
describe(algorithm, () => {
fixtures.forEach(f => {
const fn = bcrypto[algorithm];
const expected = f[algorithm];
const fn: (x: Buffer) => Buffer = bcrypto[algorithm];
const expected: string = f[algorithm];
it('returns ' + expected + ' for ' + f.hex, () => {
const data = Buffer.from(f.hex, 'hex');

25
ts_test/ecpair.ts

@ -1,5 +1,6 @@
import { ECPair } from '..';
import { ECPair, ECPairInterface } from '..';
import { networks as NETWORKS } from '..';
import { FixtureECPair } from './fixtureTypes';
const { describe, it, beforeEach } = require('mocha');
const assert = require('assert');
const proxyquire = require('proxyquire');
@ -7,7 +8,7 @@ const hoodwink = require('hoodwink');
const tinysecp = require('tiny-secp256k1');
const fixtures = require('../ts_test/fixtures/ecpair.json');
const fixtures: FixtureECPair = require('../ts_test/fixtures/ecpair.json');
const NETWORKS_LIST = []; // Object.values(NETWORKS)
for (const networkName in NETWORKS) {
@ -30,7 +31,7 @@ const GROUP_ORDER_LESS_1 = Buffer.from(
describe('ECPair', () => {
describe('getPublicKey', () => {
let keyPair;
let keyPair: ECPairInterface;
beforeEach(() => {
keyPair = ECPair.fromPrivateKey(ONE);
@ -39,6 +40,7 @@ describe('ECPair', () => {
it(
'calls pointFromScalar lazily',
hoodwink(() => {
// @ts-ignore
assert.strictEqual(keyPair.__Q, undefined);
// .publicKey forces the memoization
@ -47,6 +49,7 @@ describe('ECPair', () => {
'0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
);
assert.strictEqual(
// @ts-ignore
keyPair.__Q.toString('hex'),
'0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
);
@ -93,7 +96,8 @@ describe('ECPair', () => {
it('throws ' + f.exception, () => {
const d = Buffer.from(f.d, 'hex');
assert.throws(() => {
ECPair.fromPrivateKey(d, f.options);
// @ts-ignore
ECPair.fromPrivateKey(d, f.options as ECPairInterface);
}, new RegExp(f.exception));
});
});
@ -104,7 +108,7 @@ describe('ECPair', () => {
it('throws ' + f.exception, () => {
const Q = Buffer.from(f.Q, 'hex');
assert.throws(() => {
ECPair.fromPublicKey(Q, f.options);
ECPair.fromPublicKey(Q, f.options as ECPairInterface);
}, new RegExp(f.exception));
});
});
@ -246,9 +250,9 @@ describe('ECPair', () => {
});
describe('tinysecp wrappers', () => {
let keyPair;
let hash;
let signature;
let keyPair: ECPairInterface;
let hash: Buffer;
let signature: Buffer;
beforeEach(() => {
keyPair = ECPair.makeRandom();
@ -263,7 +267,7 @@ describe('ECPair', () => {
this.mock(
tinysecp,
'sign',
(h, d) => {
(h: Buffer, d: Buffer) => {
assert.strictEqual(h, hash);
assert.strictEqual(d, keyPair.privateKey);
return signature;
@ -276,6 +280,7 @@ describe('ECPair', () => {
);
it('throws if no private key is found', () => {
// @ts-ignore
delete keyPair.__D;
assert.throws(() => {
@ -291,7 +296,7 @@ describe('ECPair', () => {
this.mock(
tinysecp,
'verify',
(h, q, s) => {
(h: Buffer, q: Buffer, s: Buffer) => {
assert.strictEqual(h, hash);
assert.strictEqual(q, keyPair.publicKey);
assert.strictEqual(s, signature);

153
ts_test/fixtureTypes.ts

@ -221,6 +221,7 @@ export type FixtureScriptNumber = [
export interface FixtureScript {
valid: Array<{
asm: string;
type?: string;
script: string;
stack?: string[];
nonstandard?: {
@ -239,23 +240,21 @@ export interface FixtureScript {
}>;
};
}
export interface FixtureSignatureRawSig {
r: string;
s: string;
}
export interface FixtureSignature {
valid: Array<{
hex: string;
hashType: number;
raw: {
r: string;
s: string;
};
raw: FixtureSignatureRawSig;
}>;
invalid: Array<{
exception: string;
hex: string;
hashType?: number;
raw?: {
r: string;
s: string;
};
raw?: FixtureSignatureRawSig;
}>;
}
export interface FixtureTemplateInput {
@ -333,36 +332,43 @@ export interface FixtureTemplates {
};
};
}
export interface FixtureTransactionBuilder {
valid: {
build: Array<{
description: string;
txHex: string;
version?: number | null;
locktime?: number;
export interface FixtureTransactionBuilderValidBuild {
description: string;
exception?: string;
txHex: string;
txHexAfter?: string;
version?: number | null;
locktime?: number;
network?: string;
incomplete?: boolean;
stages?: string[];
outputs: Array<{
script: string;
value: number;
}>;
inputs: Array<{
vout: number;
txHex?: string;
txId?: string;
sequence?: number;
scriptSig?: string;
scriptSigAfter?: string;
prevTxScript?: string;
signs: Array<{
keyPair: string;
throws?: boolean;
stage?: string;
value?: number;
witnessScript?: string;
redeemScript?: string;
network?: string;
incomplete?: boolean;
outputs: Array<{
script: string;
value: number;
}>;
inputs: Array<{
vout: number;
txHex?: string;
txId?: string;
sequence?: number;
prevTxScript?: string;
signs: Array<{
keyPair: string;
throws?: boolean;
value?: number;
witnessScript?: string;
redeemScript?: string;
network?: string;
hashType?: number;
}>;
}>;
hashType?: number;
}>;
}>;
}
export interface FixtureTransactionBuilder {
valid: {
build: FixtureTransactionBuilderValidBuild[];
fromTransaction: Array<{
description: string;
network: string;
@ -376,6 +382,8 @@ export interface FixtureTransactionBuilder {
txHex?: string;
txId?: string;
prevTxScript?: string;
scriptSig?: string;
scriptSigAfter?: string;
signs: Array<{
keyPair: string;
throws?: boolean;
@ -387,23 +395,7 @@ export interface FixtureTransactionBuilder {
}>;
}>;
}>;
fromTransactionSequential: Array<{
description: string;
network: string;
txHex: string;
txHexAfter: string;
version: number;
incomplete: boolean;
inputs: Array<{
vout: number;
scriptSig: string;
scriptSigAfter: string;
signs: Array<{
keyPair: string;
redeemScript?: string;
}>;
}>;
}>;
fromTransactionSequential: FixtureTransactionBuilderValidBuild[];
classification: {
hex: string;
};
@ -420,6 +412,7 @@ export interface FixtureTransactionBuilder {
vout: number;
txHex?: string;
txId?: string;
redeemScript?: string;
prevTxScript?: string;
signs: Array<{
keyPair: string;
@ -427,6 +420,8 @@ export interface FixtureTransactionBuilder {
value?: number;
witnessScript?: string;
redeemScript?: string;
scriptSigBefore?: string;
scriptSig?: string;
network?: string;
hashType?: number;
}>;
@ -434,56 +429,8 @@ export interface FixtureTransactionBuilder {
}>;
};
invalid: {
build: Array<{
exception: string;
description?: string;
network?: string;
incomplete?: boolean;
txHex?: string;
outputs?: Array<{
script: string;
value: number;
}>;
inputs?: Array<{
vout: number;
txHex?: string;
txId?: string;
prevTxScript?: string;
signs: Array<{
keyPair: string;
throws?: boolean;
value?: number;
witnessScript?: string;
redeemScript?: string;
network?: string;
hashType?: number;
}>;
}>;
}>;
sign: Array<{
description?: string;
network?: string;
exception: string;
inputs: Array<{
vout: number;
txHex?: string;
txId?: string;
prevTxScript?: string;
signs: Array<{
keyPair: string;
throws?: boolean;
value?: number;
witnessScript?: string;
redeemScript?: string;
network?: string;
hashType?: number;
}>;
}>;
outputs: Array<{
script: string;
value: number;
}>;
}>;
build: FixtureTransactionBuilderValidBuild[];
sign: FixtureTransactionBuilderValidBuild[];
fromTransaction: Array<{
exception: string;
txHex: string;

7
ts_test/script.ts

@ -1,10 +1,11 @@
import { script as bscript } from '..';
import { FixtureScript, FixtureTemplates } from './fixtureTypes';
const { describe, it } = require('mocha');
const assert = require('assert');
const minimalData = require('minimaldata');
const fixtures = require('../ts_test/fixtures/script.json');
const fixtures2 = require('../ts_test/fixtures/templates.json');
const fixtures: FixtureScript = require('../ts_test/fixtures/script.json');
const fixtures2: FixtureTemplates = require('../ts_test/fixtures/templates.json');
describe('script', () => {
// TODO
@ -161,7 +162,7 @@ describe('script', () => {
});
});
function testEncodingForSize(i): void {
function testEncodingForSize(i: number): void {
it('compliant for data PUSH of length ' + i, () => {
const buffer = Buffer.alloc(i);
const script = bscript.compile([buffer]);

3
ts_test/script_number.ts

@ -1,8 +1,9 @@
import { script } from '..';
import { FixtureScriptNumber } from './fixtureTypes';
const { describe, it } = require('mocha');
const assert = require('assert');
const scriptNumber = script.number;
const fixtures = require('../ts_test/fixtures/script_number.json');
const fixtures: FixtureScriptNumber = require('../ts_test/fixtures/script_number.json');
describe('script-number', () => {
describe('decode', () => {

7
ts_test/script_signature.ts

@ -1,18 +1,19 @@
import { script } from '..';
import { FixtureSignature, FixtureSignatureRawSig } from './fixtureTypes';
const { describe, it } = require('mocha');
const assert = require('assert');
const bscriptSig = script.signature;
const fixtures = require('../ts_test/fixtures/signature.json');
const fixtures: FixtureSignature = require('../ts_test/fixtures/signature.json');
describe('Script Signatures', () => {
function fromRaw(signature): Buffer {
function fromRaw(signature: FixtureSignatureRawSig): Buffer {
return Buffer.concat(
[Buffer.from(signature.r, 'hex'), Buffer.from(signature.s, 'hex')],
64,
);
}
function toRaw(signature): any {
function toRaw(signature: Buffer): FixtureSignatureRawSig {
return {
r: signature.slice(0, 32).toString('hex'),
s: signature.slice(32, 64).toString('hex'),

68
ts_test/transaction_builder.ts

@ -7,22 +7,29 @@ import {
Transaction,
TransactionBuilder,
} from '..';
import {
FixtureTransactionBuilder,
FixtureTransactionBuilderValidBuild,
} from './fixtureTypes';
const { describe, it, beforeEach } = require('mocha');
const assert = require('assert');
const fixtures = require('../ts_test/fixtures/transaction_builder');
const fixtures: FixtureTransactionBuilder = require('../ts_test/fixtures/transaction_builder');
function constructSign(f, txb): TransactionBuilder {
function constructSign(
f: FixtureTransactionBuilderValidBuild,
txb: TransactionBuilder,
): TransactionBuilder {
const network = NETWORKS[f.network];
const stages = f.stages && f.stages.concat();
const stages: string[] = f.stages && f.stages.concat();
f.inputs.forEach((input, index) => {
if (!input.signs) return;
input.signs.forEach(sign => {
const keyPair = ECPair.fromWIF(sign.keyPair, network);
let redeemScript;
let witnessScript;
let value;
let redeemScript: Buffer;
let witnessScript: Buffer;
let value: number;
if (sign.redeemScript) {
redeemScript = bscript.fromASM(sign.redeemScript);
@ -56,7 +63,10 @@ function constructSign(f, txb): TransactionBuilder {
return txb;
}
function construct(f, dontSign?): TransactionBuilder {
function construct(
f: FixtureTransactionBuilderValidBuild,
dontSign?: boolean,
): TransactionBuilder {
const network = NETWORKS[f.network];
const txb = new TransactionBuilder(network);
@ -64,8 +74,8 @@ function construct(f, dontSign?): TransactionBuilder {
if (Number.isFinite(f.version)) txb.setVersion(f.version);
if (f.locktime !== undefined) txb.setLockTime(f.locktime);
f.inputs.forEach(input => {
let prevTx;
f.inputs.forEach((input: any) => {
let prevTx: Transaction;
if (input.txRaw) {
const constructed = construct(input.txRaw);
if (input.txRaw.incomplete) prevTx = constructed.buildIncomplete();
@ -76,7 +86,7 @@ function construct(f, dontSign?): TransactionBuilder {
prevTx = input.txId;
}
let prevTxScript;
let prevTxScript: Buffer;
if (input.prevTxScript) {
prevTxScript = bscript.fromASM(input.prevTxScript);
}
@ -84,7 +94,7 @@ function construct(f, dontSign?): TransactionBuilder {
txb.addInput(prevTx, input.vout, input.sequence, prevTxScript);
});
f.outputs.forEach(output => {
f.outputs.forEach((output: any) => {
if (output.address) {
txb.addOutput(output.address, output.value);
} else {
@ -197,10 +207,12 @@ describe('TransactionBuilder', () => {
const txb = TransactionBuilder.fromTransaction(tx);
// @ts-ignore
txb.__INPUTS.forEach(i => {
assert.strictEqual(i.prevOutType, 'scripthash');
assert.strictEqual(i.redeemScriptType, 'multisig');
});
txb.__INPUTS.forEach(
(i: { prevOutType?: string; redeemScriptType?: string }) => {
assert.strictEqual(i.prevOutType, 'scripthash');
assert.strictEqual(i.redeemScriptType, 'multisig');
},
);
});
fixtures.invalid.fromTransaction.forEach(f => {
@ -215,7 +227,7 @@ describe('TransactionBuilder', () => {
});
describe('addInput', () => {
let txb;
let txb: TransactionBuilder;
beforeEach(() => {
txb = new TransactionBuilder();
});
@ -224,10 +236,12 @@ describe('TransactionBuilder', () => {
const vin = txb.addInput(txHash, 1, 54);
assert.strictEqual(vin, 0);
// @ts-ignore
const txIn = txb.__TX.ins[0];
assert.strictEqual(txIn.hash, txHash);
assert.strictEqual(txIn.index, 1);
assert.strictEqual(txIn.sequence, 54);
// @ts-ignore
assert.strictEqual(txb.__INPUTS[0].prevOutScript, undefined);
});
@ -235,10 +249,12 @@ describe('TransactionBuilder', () => {
const vin = txb.addInput(txHash, 1, 54, scripts[1]);
assert.strictEqual(vin, 0);
// @ts-ignore
const txIn = txb.__TX.ins[0];
assert.strictEqual(txIn.hash, txHash);
assert.strictEqual(txIn.index, 1);
assert.strictEqual(txIn.sequence, 54);
// @ts-ignore
assert.strictEqual(txb.__INPUTS[0].prevOutScript, scripts[1]);
});
@ -250,10 +266,12 @@ describe('TransactionBuilder', () => {
const vin = txb.addInput(prevTx, 1, 54);
assert.strictEqual(vin, 0);
// @ts-ignore
const txIn = txb.__TX.ins[0];
assert.deepStrictEqual(txIn.hash, prevTx.getHash());
assert.strictEqual(txIn.index, 1);
assert.strictEqual(txIn.sequence, 54);
// @ts-ignore
assert.strictEqual(txb.__INPUTS[0].prevOutScript, scripts[1]);
});
@ -274,7 +292,7 @@ describe('TransactionBuilder', () => {
});
describe('addOutput', () => {
let txb;
let txb: TransactionBuilder;
beforeEach(() => {
txb = new TransactionBuilder();
});
@ -284,6 +302,7 @@ describe('TransactionBuilder', () => {
const vout = txb.addOutput(address, 1000);
assert.strictEqual(vout, 0);
// @ts-ignore
const txout = txb.__TX.outs[0];
assert.deepStrictEqual(txout.script, scripts[0]);
assert.strictEqual(txout.value, 1000);
@ -293,6 +312,7 @@ describe('TransactionBuilder', () => {
const vout = txb.addOutput(scripts[0], 1000);
assert.strictEqual(vout, 0);
// @ts-ignore
const txout = txb.__TX.outs[0];
assert.deepStrictEqual(txout.script, scripts[0]);
assert.strictEqual(txout.value, 1000);
@ -364,7 +384,7 @@ describe('TransactionBuilder', () => {
return Buffer.alloc(32, 1);
},
}).publicKey,
sign: (hash): Buffer => {
sign: (): Buffer => {
return Buffer.alloc(64, 0x5f);
},
};
@ -402,8 +422,8 @@ describe('TransactionBuilder', () => {
input.signs.forEach(sign => {
const keyPairNetwork = NETWORKS[sign.network || f.network];
const keyPair2 = ECPair.fromWIF(sign.keyPair, keyPairNetwork);
let redeemScript;
let witnessScript;
let redeemScript: Buffer;
let witnessScript: Buffer;
if (sign.redeemScript) {
redeemScript = bscript.fromASM(sign.redeemScript);
@ -459,7 +479,7 @@ describe('TransactionBuilder', () => {
describe('for ' + (f.description || f.exception), () => {
it('throws ' + f.exception, () => {
assert.throws(() => {
let txb;
let txb: TransactionBuilder;
if (f.txHex) {
txb = TransactionBuilder.fromTransaction(
Transaction.fromHex(f.txHex),
@ -476,7 +496,7 @@ describe('TransactionBuilder', () => {
if (f.incomplete) {
it('throws ' + f.exception, () => {
assert.throws(() => {
let txb;
let txb: TransactionBuilder;
if (f.txHex) {
txb = TransactionBuilder.fromTransaction(
Transaction.fromHex(f.txHex),
@ -490,7 +510,7 @@ describe('TransactionBuilder', () => {
});
} else {
it('does not throw if buildIncomplete', () => {
let txb;
let txb: TransactionBuilder;
if (f.txHex) {
txb = TransactionBuilder.fromTransaction(
Transaction.fromHex(f.txHex),
@ -578,7 +598,7 @@ describe('TransactionBuilder', () => {
it(f.description, () => {
const network = NETWORKS[f.network];
let txb = construct(f, true);
let tx;
let tx: Transaction;
f.inputs.forEach((input, i) => {
const redeemScript = bscript.fromASM(input.redeemScript);

1
types/index.d.ts

@ -11,6 +11,7 @@ export { OPS as opcodes } from './script';
export { Transaction } from './transaction';
export { TransactionBuilder } from './transaction_builder';
export { BIP32Interface } from 'bip32';
export { ECPairInterface } from './ecpair';
export { Network } from './networks';
export { Payment, PaymentOpts } from './payments';
export { OpCode } from './script';

Loading…
Cancel
Save