Skip to content

Commit 9b86c33

Browse files
committed
fix: Update to work with v6
1 parent 5f11c67 commit 9b86c33

27 files changed

+1558
-576
lines changed

package-lock.json

Lines changed: 407 additions & 468 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"bip174": "^2.0.1",
5454
"bs58check": "^2.1.2",
5555
"create-hash": "^1.1.0",
56+
"fastpriorityqueue": "^0.7.1",
5657
"ripemd160": "^2.0.2",
5758
"typeforce": "^1.11.3",
5859
"varuint-bitcoin": "^1.1.2",
@@ -86,7 +87,7 @@
8687
"randombytes": "^2.1.0",
8788
"regtest-client": "0.2.0",
8889
"rimraf": "^2.6.3",
89-
"tiny-secp256k1": "^2.1.2",
90+
"tiny-secp256k1": "^2.2.0",
9091
"ts-node": "^8.3.0",
9192
"tslint": "^6.1.3",
9293
"typescript": "^4.4.4"

src/address.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ function fromOutputScript(output, network) {
9999
try {
100100
return payments.p2wsh({ output, network }).address;
101101
} catch (e) {}
102+
try {
103+
return payments.p2tr({ output, network }).address;
104+
} catch (e) {}
102105
try {
103106
return _toFutureSegwitAddress(output, network);
104107
} catch (e) {}

src/index.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import * as crypto from './crypto';
33
import * as networks from './networks';
44
import * as payments from './payments';
55
import * as script from './script';
6-
export { address, crypto, networks, payments, script };
6+
import * as taproot from './taproot';
7+
export { address, crypto, networks, payments, script, taproot };
78
export { Block } from './block';
89
export { TaggedHashPrefix } from './crypto';
910
export { Psbt, PsbtTxInput, PsbtTxOutput, Signer, SignerAsync, HDSigner, HDSignerAsync, } from './psbt';

src/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22
Object.defineProperty(exports, '__esModule', { value: true });
3-
exports.Transaction = exports.opcodes = exports.Psbt = exports.Block = exports.script = exports.payments = exports.networks = exports.crypto = exports.address = void 0;
3+
exports.Transaction = exports.opcodes = exports.Psbt = exports.Block = exports.taproot = exports.script = exports.payments = exports.networks = exports.crypto = exports.address = void 0;
44
const address = require('./address');
55
exports.address = address;
66
const crypto = require('./crypto');
@@ -11,6 +11,8 @@ const payments = require('./payments');
1111
exports.payments = payments;
1212
const script = require('./script');
1313
exports.script = script;
14+
const taproot = require('./taproot');
15+
exports.taproot = taproot;
1416
var block_1 = require('./block');
1517
Object.defineProperty(exports, 'Block', {
1618
enumerable: true,

src/payments/index.d.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
/// <reference types="node" />
22
import { Network } from '../networks';
3+
import { TinySecp256k1Interface } from '../types';
34
import { p2data as embed } from './embed';
45
import { p2ms } from './p2ms';
56
import { p2pk } from './p2pk';
67
import { p2pkh } from './p2pkh';
78
import { p2sh } from './p2sh';
9+
import { p2tr } from './p2tr';
10+
import { p2tr_ns } from './p2tr_ns';
811
import { p2wpkh } from './p2wpkh';
912
import { p2wsh } from './p2wsh';
1013
export interface Payment {
@@ -22,15 +25,21 @@ export interface Payment {
2225
address?: string;
2326
hash?: Buffer;
2427
redeem?: Payment;
28+
redeems?: Payment[];
29+
redeemIndex?: number;
2530
witness?: Buffer[];
31+
weight?: number;
32+
controlBlock?: Buffer;
33+
annex?: Buffer;
2634
}
2735
export declare type PaymentCreator = (a: Payment, opts?: PaymentOpts) => Payment;
2836
export declare type PaymentFunction = () => Payment;
2937
export interface PaymentOpts {
3038
validate?: boolean;
3139
allowIncomplete?: boolean;
40+
eccLib?: TinySecp256k1Interface;
3241
}
3342
export declare type StackElement = Buffer | number;
3443
export declare type Stack = StackElement[];
3544
export declare type StackFunction = () => Stack;
36-
export { embed, p2ms, p2pk, p2pkh, p2sh, p2wpkh, p2wsh };
45+
export { embed, p2ms, p2pk, p2pkh, p2sh, p2tr, p2tr_ns, p2wpkh, p2wsh };

src/payments/index.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22
Object.defineProperty(exports, '__esModule', { value: true });
3-
exports.p2wsh = exports.p2wpkh = exports.p2sh = exports.p2pkh = exports.p2pk = exports.p2ms = exports.embed = void 0;
3+
exports.p2wsh = exports.p2wpkh = exports.p2tr_ns = exports.p2tr = exports.p2sh = exports.p2pkh = exports.p2pk = exports.p2ms = exports.embed = void 0;
44
const embed_1 = require('./embed');
55
Object.defineProperty(exports, 'embed', {
66
enumerable: true,
@@ -36,6 +36,20 @@ Object.defineProperty(exports, 'p2sh', {
3636
return p2sh_1.p2sh;
3737
},
3838
});
39+
const p2tr_1 = require('./p2tr');
40+
Object.defineProperty(exports, 'p2tr', {
41+
enumerable: true,
42+
get: function() {
43+
return p2tr_1.p2tr;
44+
},
45+
});
46+
const p2tr_ns_1 = require('./p2tr_ns');
47+
Object.defineProperty(exports, 'p2tr_ns', {
48+
enumerable: true,
49+
get: function() {
50+
return p2tr_ns_1.p2tr_ns;
51+
},
52+
});
3953
const p2wpkh_1 = require('./p2wpkh');
4054
Object.defineProperty(exports, 'p2wpkh', {
4155
enumerable: true,

src/payments/p2tr.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import { Payment, PaymentOpts } from './index';
2+
export declare function p2tr(a: Payment, opts?: PaymentOpts): Payment;

0 commit comments

Comments
 (0)