@btc-vision/bitcoin 6.5.3 → 6.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/address.d.ts +2 -6
- package/browser/bech32utils.d.ts +6 -0
- package/browser/chunks/{crypto-0PweVewC.js → crypto-BhCpKpek.js} +4 -4
- package/browser/chunks/{payments-CgasufRS.js → payments-yjA0Evsv.js} +639 -597
- package/browser/chunks/{psbt-BIwOrKer.js → psbt-URK2hBFc.js} +1259 -1316
- package/browser/chunks/{script-CROJPzz_.js → script-DyPItFEl.js} +33 -33
- package/browser/chunks/{transaction-DchBu35N.js → transaction-C_UbhMGn.js} +3 -3
- package/browser/chunks/{utils-CO5kmxe9.js → utils-DNZi-T5W.js} +26 -26
- package/browser/index.d.ts +3 -1
- package/browser/index.js +102 -90
- package/browser/payments/embed.d.ts +1 -1
- package/browser/payments/index.d.ts +12 -104
- package/browser/payments/p2ms.d.ts +1 -1
- package/browser/payments/p2op.d.ts +1 -1
- package/browser/payments/p2pk.d.ts +1 -1
- package/browser/payments/p2pkh.d.ts +1 -1
- package/browser/payments/p2sh.d.ts +1 -1
- package/browser/payments/p2tr.d.ts +1 -1
- package/browser/payments/p2wpkh.d.ts +1 -1
- package/browser/payments/p2wsh.d.ts +1 -1
- package/browser/payments/types.d.ts +93 -0
- package/browser/psbt/bip371.d.ts +0 -1
- package/browser/psbt/psbtutils.d.ts +0 -7
- package/browser/pubkey.d.ts +8 -0
- package/browser/script.d.ts +1 -2
- package/browser/script_signature.d.ts +1 -0
- package/browser/types.d.ts +3 -0
- package/build/address.d.ts +2 -6
- package/build/address.js +19 -37
- package/build/bech32utils.d.ts +6 -0
- package/build/bech32utils.js +26 -0
- package/build/index.d.ts +3 -1
- package/build/index.js +1 -0
- package/build/payments/embed.d.ts +1 -1
- package/build/payments/embed.js +1 -1
- package/build/payments/index.d.ts +12 -104
- package/build/payments/index.js +12 -24
- package/build/payments/p2ms.d.ts +1 -1
- package/build/payments/p2ms.js +1 -1
- package/build/payments/p2op.d.ts +1 -1
- package/build/payments/p2op.js +2 -2
- package/build/payments/p2pk.d.ts +1 -1
- package/build/payments/p2pk.js +1 -1
- package/build/payments/p2pkh.d.ts +1 -1
- package/build/payments/p2pkh.js +2 -2
- package/build/payments/p2sh.d.ts +1 -1
- package/build/payments/p2sh.js +1 -1
- package/build/payments/p2tr.d.ts +1 -1
- package/build/payments/p2tr.js +2 -6
- package/build/payments/p2wpkh.d.ts +1 -1
- package/build/payments/p2wpkh.js +1 -1
- package/build/payments/p2wsh.d.ts +1 -1
- package/build/payments/p2wsh.js +2 -2
- package/build/payments/types.d.ts +93 -0
- package/build/payments/types.js +13 -0
- package/build/psbt/bip371.d.ts +0 -1
- package/build/psbt/bip371.js +2 -6
- package/build/psbt/psbtutils.d.ts +0 -7
- package/build/psbt/psbtutils.js +2 -54
- package/build/psbt.js +3 -2
- package/build/pubkey.d.ts +8 -0
- package/build/pubkey.js +56 -0
- package/build/script.d.ts +1 -2
- package/build/script.js +1 -4
- package/build/script_signature.d.ts +1 -0
- package/build/script_signature.js +4 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/types.d.ts +3 -0
- package/package.json +5 -2
- package/src/address.ts +20 -50
- package/src/bech32utils.ts +43 -0
- package/src/index.ts +2 -3
- package/src/payments/embed.ts +2 -2
- package/src/payments/index.ts +40 -164
- package/src/payments/p2ms.ts +2 -2
- package/src/payments/p2op.ts +2 -2
- package/src/payments/p2pk.ts +2 -2
- package/src/payments/p2pkh.ts +3 -3
- package/src/payments/p2sh.ts +2 -10
- package/src/payments/p2tr.ts +6 -5
- package/src/payments/p2wpkh.ts +1 -1
- package/src/payments/p2wsh.ts +8 -2
- package/src/payments/types.ts +154 -0
- package/src/psbt/bip371.ts +6 -13
- package/src/psbt/psbtutils.ts +2 -104
- package/src/psbt.ts +3 -2
- package/src/pubkey.ts +99 -0
- package/src/script.ts +2 -7
- package/src/script_signature.ts +10 -1
- package/src/types.ts +5 -0
- package/test/address.spec.ts +8 -7
- package/test/integration/taproot.spec.ts +2 -1
- package/test/payments.spec.ts +4 -4
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { Network } from '../networks.js';
|
|
2
|
+
import { Taptree } from '../types.js';
|
|
3
|
+
export declare enum PaymentType {
|
|
4
|
+
P2PK = "p2pk",
|
|
5
|
+
P2PKH = "p2pkh",
|
|
6
|
+
P2SH = "p2sh",
|
|
7
|
+
P2MS = "p2ms",
|
|
8
|
+
P2WPKH = "p2wpkh",
|
|
9
|
+
P2WSH = "p2wsh",
|
|
10
|
+
P2TR = "p2tr",
|
|
11
|
+
P2OP = "p2op",
|
|
12
|
+
Embed = "embed",
|
|
13
|
+
ScriptRedeem = "scriptRedeem"
|
|
14
|
+
}
|
|
15
|
+
export interface BasePayment {
|
|
16
|
+
name?: PaymentType;
|
|
17
|
+
network?: Network;
|
|
18
|
+
output?: Buffer;
|
|
19
|
+
input?: Buffer;
|
|
20
|
+
address?: string;
|
|
21
|
+
witness?: Buffer[];
|
|
22
|
+
redeem?: ScriptRedeem;
|
|
23
|
+
useHybrid?: boolean;
|
|
24
|
+
useUncompressed?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface ScriptRedeem extends BasePayment {
|
|
27
|
+
output?: Buffer;
|
|
28
|
+
redeemVersion?: number;
|
|
29
|
+
network?: Network;
|
|
30
|
+
}
|
|
31
|
+
export interface P2PKPayment extends BasePayment {
|
|
32
|
+
name: PaymentType.P2PK;
|
|
33
|
+
pubkey?: Buffer;
|
|
34
|
+
signature?: Buffer;
|
|
35
|
+
}
|
|
36
|
+
export interface P2PKHPayment extends BasePayment {
|
|
37
|
+
name: PaymentType.P2PKH;
|
|
38
|
+
hash?: Buffer;
|
|
39
|
+
pubkey?: Buffer;
|
|
40
|
+
signature?: Buffer;
|
|
41
|
+
}
|
|
42
|
+
export interface P2SHPayment extends BasePayment {
|
|
43
|
+
name: PaymentType.P2SH;
|
|
44
|
+
hash?: Buffer;
|
|
45
|
+
signatures?: Buffer[];
|
|
46
|
+
}
|
|
47
|
+
export interface P2MSPayment extends BasePayment {
|
|
48
|
+
name: PaymentType.P2MS;
|
|
49
|
+
m?: number;
|
|
50
|
+
n?: number;
|
|
51
|
+
pubkeys?: Buffer[];
|
|
52
|
+
signatures?: Buffer[];
|
|
53
|
+
}
|
|
54
|
+
export interface P2WPKHPayment extends BasePayment {
|
|
55
|
+
name: PaymentType.P2WPKH;
|
|
56
|
+
hash?: Buffer;
|
|
57
|
+
pubkey?: Buffer;
|
|
58
|
+
signature?: Buffer;
|
|
59
|
+
}
|
|
60
|
+
export interface P2WSHPayment extends BasePayment {
|
|
61
|
+
name: PaymentType.P2WSH;
|
|
62
|
+
hash?: Buffer;
|
|
63
|
+
redeem?: ScriptRedeem;
|
|
64
|
+
}
|
|
65
|
+
export interface P2TRPayment extends BasePayment {
|
|
66
|
+
name: PaymentType.P2TR;
|
|
67
|
+
pubkey?: Buffer;
|
|
68
|
+
internalPubkey?: Buffer;
|
|
69
|
+
hash?: Buffer;
|
|
70
|
+
scriptTree?: Taptree;
|
|
71
|
+
signature?: Buffer;
|
|
72
|
+
redeemVersion?: number;
|
|
73
|
+
redeem?: ScriptRedeem;
|
|
74
|
+
}
|
|
75
|
+
export interface P2OPPayment extends BasePayment {
|
|
76
|
+
name: PaymentType.P2OP;
|
|
77
|
+
program?: Buffer;
|
|
78
|
+
deploymentVersion: number | undefined;
|
|
79
|
+
hash160?: Buffer;
|
|
80
|
+
}
|
|
81
|
+
export interface P2OPPaymentParams extends Omit<P2OPPayment, 'name' | 'deploymentVersion'> {
|
|
82
|
+
deploymentVersion?: number;
|
|
83
|
+
}
|
|
84
|
+
export interface EmbedPayment extends BasePayment {
|
|
85
|
+
name: PaymentType.Embed;
|
|
86
|
+
data: Buffer[];
|
|
87
|
+
}
|
|
88
|
+
export type Payment = P2PKPayment | P2PKHPayment | P2SHPayment | P2MSPayment | P2WPKHPayment | P2WSHPayment | P2TRPayment | P2OPPayment | EmbedPayment | ScriptRedeem;
|
|
89
|
+
export type PaymentCreator = <T extends BasePayment>(a: T, opts?: PaymentOpts) => T;
|
|
90
|
+
export interface PaymentOpts {
|
|
91
|
+
validate?: boolean;
|
|
92
|
+
allowIncomplete?: boolean;
|
|
93
|
+
}
|
package/browser/psbt/bip371.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { Taptree } from '../types.js';
|
|
|
3
3
|
interface PsbtOutputWithScript extends PsbtOutput {
|
|
4
4
|
script?: Buffer;
|
|
5
5
|
}
|
|
6
|
-
export declare const toXOnly: (pubKey: Buffer | Uint8Array) => Buffer;
|
|
7
6
|
export declare function tapScriptFinalizer(inputIndex: number, input: PsbtInput, tapLeafHashToFinalize?: Buffer): {
|
|
8
7
|
finalScriptWitness: Buffer | undefined;
|
|
9
8
|
};
|
|
@@ -9,13 +9,6 @@ export declare const isP2TR: (script: Buffer) => boolean;
|
|
|
9
9
|
export declare const isP2OP: (script: Buffer) => boolean;
|
|
10
10
|
export declare const isP2A: (script: Buffer) => boolean;
|
|
11
11
|
export declare function witnessStackToScriptWitness(witness: Buffer[]): Buffer;
|
|
12
|
-
export interface UncompressedPublicKey {
|
|
13
|
-
hybrid: Buffer;
|
|
14
|
-
uncompressed: Buffer;
|
|
15
|
-
}
|
|
16
|
-
export declare function decompressPublicKey(realPubKey: Uint8Array | Buffer): UncompressedPublicKey | undefined;
|
|
17
|
-
export declare function bigIntTo32Bytes(num: bigint): Buffer;
|
|
18
|
-
export declare function pubkeysMatch(a: Buffer, b: Buffer): boolean;
|
|
19
12
|
export declare function pubkeyPositionInScript(pubkey: Buffer, script: Buffer): number;
|
|
20
13
|
export declare function pubkeyInScript(pubkey: Buffer, script: Buffer): boolean;
|
|
21
14
|
export declare function checkInputForSig(input: PsbtInput, action: string): boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const toXOnly: (pubKey: Buffer | Uint8Array) => Buffer;
|
|
2
|
+
export interface UncompressedPublicKey {
|
|
3
|
+
hybrid: Buffer;
|
|
4
|
+
uncompressed: Buffer;
|
|
5
|
+
}
|
|
6
|
+
export declare function bigIntTo32Bytes(num: bigint): Buffer;
|
|
7
|
+
export declare function decompressPublicKey(realPubKey: Uint8Array | Buffer): UncompressedPublicKey | undefined;
|
|
8
|
+
export declare function pubkeysMatch(a: Buffer, b: Buffer): boolean;
|
package/browser/script.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { opcodes } from './opcodes.js';
|
|
2
|
-
import { Stack } from './
|
|
2
|
+
import { Stack } from './types.js';
|
|
3
3
|
import * as scriptNumber from './script_number.js';
|
|
4
4
|
import * as scriptSignature from './script_signature.js';
|
|
5
5
|
export { opcodes };
|
|
@@ -11,7 +11,6 @@ export declare function toASM(chunks: Buffer | Array<number | Buffer>): string;
|
|
|
11
11
|
export declare function fromASM(asm: string): Buffer;
|
|
12
12
|
export declare function toStack(chunks: Buffer | Array<number | Buffer>): Buffer[];
|
|
13
13
|
export declare function isCanonicalPubKey(buffer: Buffer): boolean;
|
|
14
|
-
export declare function isDefinedHashType(hashType: number): boolean;
|
|
15
14
|
export declare function isCanonicalScriptSignature(buffer: Buffer): boolean;
|
|
16
15
|
export declare const number: typeof scriptNumber;
|
|
17
16
|
export declare const signature: typeof scriptSignature;
|
package/browser/types.d.ts
CHANGED
|
@@ -37,3 +37,6 @@ export declare const Function: TypeforceValidator;
|
|
|
37
37
|
export declare const BufferN: (n: number) => TypeforceValidator;
|
|
38
38
|
export declare const Null: TypeforceValidator;
|
|
39
39
|
export declare const oneOf: (...types: unknown[]) => TypeforceValidator;
|
|
40
|
+
export type StackElement = globalThis.Buffer | number;
|
|
41
|
+
export type Stack = StackElement[];
|
|
42
|
+
export type StackFunction = () => Stack;
|
package/build/address.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
+
import { fromBech32, type Bech32Result } from './bech32utils.js';
|
|
1
2
|
import { Network } from './networks.js';
|
|
3
|
+
export { fromBech32, type Bech32Result };
|
|
2
4
|
export interface Base58CheckResult {
|
|
3
5
|
hash: Buffer;
|
|
4
6
|
version: number;
|
|
5
7
|
}
|
|
6
|
-
export interface Bech32Result {
|
|
7
|
-
version: number;
|
|
8
|
-
prefix: string;
|
|
9
|
-
data: Buffer;
|
|
10
|
-
}
|
|
11
8
|
export declare const FUTURE_SEGWIT_MAX_SIZE: number;
|
|
12
9
|
export declare const FUTURE_SEGWIT_MIN_SIZE: number;
|
|
13
10
|
export declare const FUTURE_SEGWIT_MAX_VERSION: number;
|
|
@@ -19,7 +16,6 @@ export declare const isUnknownSegwitVersion: (output: Buffer) => boolean;
|
|
|
19
16
|
export declare function toFutureOPNetAddress(output: Buffer, network: Network): string;
|
|
20
17
|
export declare function _toFutureSegwitAddress(output: Buffer, network: Network): string;
|
|
21
18
|
export declare function fromBase58Check(address: string): Base58CheckResult;
|
|
22
|
-
export declare function fromBech32(address: string): Bech32Result;
|
|
23
19
|
export declare function toBase58Check(hash: Buffer, version: number): string;
|
|
24
20
|
export declare function toBech32(data: Buffer, version: number, prefix: string, prefixOpnet?: string): string;
|
|
25
21
|
export declare function fromOutputScript(output: Buffer, network?: Network): string;
|
package/build/address.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { bech32, bech32m } from 'bech32';
|
|
2
2
|
import * as bs58check from 'bs58check';
|
|
3
|
+
import { fromBech32 } from './bech32utils.js';
|
|
3
4
|
import * as networks from './networks.js';
|
|
5
|
+
import { p2op } from './payments/p2op.js';
|
|
6
|
+
import { p2pkh } from './payments/p2pkh.js';
|
|
7
|
+
import { p2sh } from './payments/p2sh.js';
|
|
8
|
+
import { p2tr } from './payments/p2tr.js';
|
|
9
|
+
import { p2wpkh } from './payments/p2wpkh.js';
|
|
10
|
+
import { p2wsh } from './payments/p2wsh.js';
|
|
4
11
|
import * as bscript from './script.js';
|
|
5
12
|
import { opcodes } from './script.js';
|
|
6
13
|
import { Hash160bit, tuple, typeforce, UInt8 } from './types.js';
|
|
7
|
-
|
|
14
|
+
export { fromBech32 };
|
|
8
15
|
export const FUTURE_SEGWIT_MAX_SIZE = 40;
|
|
9
16
|
export const FUTURE_SEGWIT_MIN_SIZE = 2;
|
|
10
17
|
export const FUTURE_SEGWIT_MAX_VERSION = 15;
|
|
@@ -88,31 +95,6 @@ export function fromBase58Check(address) {
|
|
|
88
95
|
const hash = Buffer.from(payload.subarray(1));
|
|
89
96
|
return { version, hash };
|
|
90
97
|
}
|
|
91
|
-
export function fromBech32(address) {
|
|
92
|
-
let result;
|
|
93
|
-
let version;
|
|
94
|
-
try {
|
|
95
|
-
result = bech32.decode(address);
|
|
96
|
-
}
|
|
97
|
-
catch (e) { }
|
|
98
|
-
if (result) {
|
|
99
|
-
version = result.words[0];
|
|
100
|
-
if (version !== 0)
|
|
101
|
-
throw new TypeError(address + ' uses wrong encoding');
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
result = bech32m.decode(address);
|
|
105
|
-
version = result.words[0];
|
|
106
|
-
if (version === 0)
|
|
107
|
-
throw new TypeError(address + ' uses wrong encoding');
|
|
108
|
-
}
|
|
109
|
-
const data = bech32.fromWords(result.words.slice(1));
|
|
110
|
-
return {
|
|
111
|
-
version,
|
|
112
|
-
prefix: result.prefix,
|
|
113
|
-
data: Buffer.from(data),
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
98
|
export function toBase58Check(hash, version) {
|
|
117
99
|
typeforce(tuple(Hash160bit, UInt8), [hash, version]);
|
|
118
100
|
const payload = Buffer.allocUnsafe(21);
|
|
@@ -131,23 +113,23 @@ export function toBech32(data, version, prefix, prefixOpnet) {
|
|
|
131
113
|
export function fromOutputScript(output, network) {
|
|
132
114
|
network = network || networks.bitcoin;
|
|
133
115
|
try {
|
|
134
|
-
return
|
|
116
|
+
return p2pkh({ output, network }).address;
|
|
135
117
|
}
|
|
136
118
|
catch (e) { }
|
|
137
119
|
try {
|
|
138
|
-
return
|
|
120
|
+
return p2sh({ output, network }).address;
|
|
139
121
|
}
|
|
140
122
|
catch (e) { }
|
|
141
123
|
try {
|
|
142
|
-
return
|
|
124
|
+
return p2wpkh({ output, network }).address;
|
|
143
125
|
}
|
|
144
126
|
catch (e) { }
|
|
145
127
|
try {
|
|
146
|
-
return
|
|
128
|
+
return p2wsh({ output, network }).address;
|
|
147
129
|
}
|
|
148
130
|
catch (e) { }
|
|
149
131
|
try {
|
|
150
|
-
return
|
|
132
|
+
return p2tr({ output, network }).address;
|
|
151
133
|
}
|
|
152
134
|
catch (e) { }
|
|
153
135
|
try {
|
|
@@ -170,9 +152,9 @@ export function toOutputScript(address, network) {
|
|
|
170
152
|
catch (e) { }
|
|
171
153
|
if (decodeBase58) {
|
|
172
154
|
if (decodeBase58.version === network.pubKeyHash)
|
|
173
|
-
return
|
|
155
|
+
return p2pkh({ hash: decodeBase58.hash }).output;
|
|
174
156
|
if (decodeBase58.version === network.scriptHash)
|
|
175
|
-
return
|
|
157
|
+
return p2sh({ hash: decodeBase58.hash }).output;
|
|
176
158
|
}
|
|
177
159
|
else {
|
|
178
160
|
try {
|
|
@@ -186,18 +168,18 @@ export function toOutputScript(address, network) {
|
|
|
186
168
|
throw new Error(address + ' has an invalid prefix');
|
|
187
169
|
if (decodeBech32.version === 0) {
|
|
188
170
|
if (decodeBech32.data.length === 20)
|
|
189
|
-
return
|
|
171
|
+
return p2wpkh({ hash: decodeBech32.data }).output;
|
|
190
172
|
if (decodeBech32.data.length === 32)
|
|
191
|
-
return
|
|
173
|
+
return p2wsh({ hash: decodeBech32.data }).output;
|
|
192
174
|
}
|
|
193
175
|
else if (decodeBech32.version === 1) {
|
|
194
176
|
if (decodeBech32.data.length === 32)
|
|
195
|
-
return
|
|
177
|
+
return p2tr({ pubkey: decodeBech32.data }).output;
|
|
196
178
|
}
|
|
197
179
|
else if (decodeBech32.version === FUTURE_OPNET_VERSION) {
|
|
198
180
|
if (!network.bech32Opnet)
|
|
199
181
|
throw new Error(address + ' has an invalid prefix');
|
|
200
|
-
return
|
|
182
|
+
return p2op({
|
|
201
183
|
program: decodeBech32.data,
|
|
202
184
|
network,
|
|
203
185
|
}).output;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { bech32, bech32m } from 'bech32';
|
|
2
|
+
export function fromBech32(address) {
|
|
3
|
+
let result;
|
|
4
|
+
let version;
|
|
5
|
+
try {
|
|
6
|
+
result = bech32.decode(address);
|
|
7
|
+
}
|
|
8
|
+
catch (e) { }
|
|
9
|
+
if (result) {
|
|
10
|
+
version = result.words[0];
|
|
11
|
+
if (version !== 0)
|
|
12
|
+
throw new TypeError(address + ' uses wrong encoding');
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
result = bech32m.decode(address);
|
|
16
|
+
version = result.words[0];
|
|
17
|
+
if (version === 0)
|
|
18
|
+
throw new TypeError(address + ' uses wrong encoding');
|
|
19
|
+
}
|
|
20
|
+
const data = bech32.fromWords(result.words.slice(1));
|
|
21
|
+
return {
|
|
22
|
+
version,
|
|
23
|
+
prefix: result.prefix,
|
|
24
|
+
data: Buffer.from(data),
|
|
25
|
+
};
|
|
26
|
+
}
|
package/build/index.d.ts
CHANGED
|
@@ -18,7 +18,8 @@ export { Transaction } from './transaction.js';
|
|
|
18
18
|
export type { Network } from './networks.js';
|
|
19
19
|
export { initEccLib } from './ecc_lib.js';
|
|
20
20
|
export { PaymentType } from './payments/index.js';
|
|
21
|
-
export type { Payment, PaymentCreator, PaymentOpts,
|
|
21
|
+
export type { Payment, PaymentCreator, PaymentOpts, P2WSHPayment, P2PKPayment, BasePayment, P2SHPayment, P2TRPayment, P2WPKHPayment, P2PKHPayment, P2MSPayment, EmbedPayment, P2OPPayment, P2OPPaymentParams, } from './payments/index.js';
|
|
22
|
+
export type { Stack, StackElement, StackFunction } from './types.js';
|
|
22
23
|
export type { Input as TxInput, Output as TxOutput } from './transaction.js';
|
|
23
24
|
export interface PsbtInput extends _PsbtInput {
|
|
24
25
|
}
|
|
@@ -47,6 +48,7 @@ export * from './address.js';
|
|
|
47
48
|
export * from './bufferutils.js';
|
|
48
49
|
export * from './payments/bip341.js';
|
|
49
50
|
export * from './psbt/psbtutils.js';
|
|
51
|
+
export { toXOnly, decompressPublicKey, pubkeysMatch, type UncompressedPublicKey } from './pubkey.js';
|
|
50
52
|
export { TAPLEAF_VERSION_MASK } from './types.js';
|
|
51
53
|
export type { Taptree, XOnlyPointAddTweakResult, Tapleaf, TinySecp256k1Interface, } from './types.js';
|
|
52
54
|
declare const bitcoin: {
|
package/build/index.js
CHANGED
|
@@ -21,6 +21,7 @@ export * from './address.js';
|
|
|
21
21
|
export * from './bufferutils.js';
|
|
22
22
|
export * from './payments/bip341.js';
|
|
23
23
|
export * from './psbt/psbtutils.js';
|
|
24
|
+
export { toXOnly, decompressPublicKey, pubkeysMatch } from './pubkey.js';
|
|
24
25
|
export { TAPLEAF_VERSION_MASK } from './types.js';
|
|
25
26
|
const bitcoin = {
|
|
26
27
|
networks,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { EmbedPayment, PaymentOpts } from './
|
|
1
|
+
import { EmbedPayment, PaymentOpts } from './types.js';
|
|
2
2
|
export declare function p2data(a: Omit<EmbedPayment, 'name'>, opts?: PaymentOpts): EmbedPayment;
|
package/build/payments/embed.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { bitcoin as BITCOIN_NETWORK } from '../networks.js';
|
|
2
2
|
import * as bscript from '../script.js';
|
|
3
3
|
import { stacksEqual, typeforce as typef } from '../types.js';
|
|
4
|
-
import { PaymentType } from './
|
|
4
|
+
import { PaymentType } from './types.js';
|
|
5
5
|
import * as lazy from './lazy.js';
|
|
6
6
|
const OPS = bscript.opcodes;
|
|
7
7
|
export function p2data(a, opts) {
|
|
@@ -1,104 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export * from './p2op.js';
|
|
14
|
-
export declare enum PaymentType {
|
|
15
|
-
P2PK = "p2pk",
|
|
16
|
-
P2PKH = "p2pkh",
|
|
17
|
-
P2SH = "p2sh",
|
|
18
|
-
P2MS = "p2ms",
|
|
19
|
-
P2WPKH = "p2wpkh",
|
|
20
|
-
P2WSH = "p2wsh",
|
|
21
|
-
P2TR = "p2tr",
|
|
22
|
-
P2OP = "p2op",
|
|
23
|
-
Embed = "embed",
|
|
24
|
-
ScriptRedeem = "scriptRedeem"
|
|
25
|
-
}
|
|
26
|
-
export interface BasePayment {
|
|
27
|
-
name?: PaymentType;
|
|
28
|
-
network?: Network;
|
|
29
|
-
output?: Buffer;
|
|
30
|
-
input?: Buffer;
|
|
31
|
-
address?: string;
|
|
32
|
-
witness?: Buffer[];
|
|
33
|
-
redeem?: ScriptRedeem;
|
|
34
|
-
useHybrid?: boolean;
|
|
35
|
-
useUncompressed?: boolean;
|
|
36
|
-
}
|
|
37
|
-
export interface ScriptRedeem extends BasePayment {
|
|
38
|
-
output?: Buffer;
|
|
39
|
-
redeemVersion?: number;
|
|
40
|
-
network?: Network;
|
|
41
|
-
}
|
|
42
|
-
export interface P2PKPayment extends BasePayment {
|
|
43
|
-
name: PaymentType.P2PK;
|
|
44
|
-
pubkey?: Buffer;
|
|
45
|
-
signature?: Buffer;
|
|
46
|
-
}
|
|
47
|
-
export interface P2PKHPayment extends BasePayment {
|
|
48
|
-
name: PaymentType.P2PKH;
|
|
49
|
-
hash?: Buffer;
|
|
50
|
-
pubkey?: Buffer;
|
|
51
|
-
signature?: Buffer;
|
|
52
|
-
}
|
|
53
|
-
export interface P2SHPayment extends BasePayment {
|
|
54
|
-
name: PaymentType.P2SH;
|
|
55
|
-
hash?: Buffer;
|
|
56
|
-
signatures?: Buffer[];
|
|
57
|
-
}
|
|
58
|
-
export interface P2MSPayment extends BasePayment {
|
|
59
|
-
name: PaymentType.P2MS;
|
|
60
|
-
m?: number;
|
|
61
|
-
n?: number;
|
|
62
|
-
pubkeys?: Buffer[];
|
|
63
|
-
signatures?: Buffer[];
|
|
64
|
-
}
|
|
65
|
-
export interface P2WPKHPayment extends BasePayment {
|
|
66
|
-
name: PaymentType.P2WPKH;
|
|
67
|
-
hash?: Buffer;
|
|
68
|
-
pubkey?: Buffer;
|
|
69
|
-
signature?: Buffer;
|
|
70
|
-
}
|
|
71
|
-
export interface P2WSHPayment extends BasePayment {
|
|
72
|
-
name: PaymentType.P2WSH;
|
|
73
|
-
hash?: Buffer;
|
|
74
|
-
redeem?: ScriptRedeem;
|
|
75
|
-
}
|
|
76
|
-
export interface P2TRPayment extends BasePayment {
|
|
77
|
-
name: PaymentType.P2TR;
|
|
78
|
-
pubkey?: Buffer;
|
|
79
|
-
internalPubkey?: Buffer;
|
|
80
|
-
hash?: Buffer;
|
|
81
|
-
scriptTree?: Taptree;
|
|
82
|
-
signature?: Buffer;
|
|
83
|
-
redeemVersion?: number;
|
|
84
|
-
redeem?: ScriptRedeem;
|
|
85
|
-
}
|
|
86
|
-
export interface P2OPPayment extends BasePayment {
|
|
87
|
-
name: PaymentType.P2OP;
|
|
88
|
-
program?: Buffer;
|
|
89
|
-
deploymentVersion: number | undefined;
|
|
90
|
-
hash160?: Buffer;
|
|
91
|
-
}
|
|
92
|
-
export interface EmbedPayment extends BasePayment {
|
|
93
|
-
name: PaymentType.Embed;
|
|
94
|
-
data: Buffer[];
|
|
95
|
-
}
|
|
96
|
-
export type Payment = P2PKPayment | P2PKHPayment | P2SHPayment | P2MSPayment | P2WPKHPayment | P2WSHPayment | P2TRPayment | P2OPPayment | EmbedPayment | ScriptRedeem;
|
|
97
|
-
export type PaymentCreator = <T extends BasePayment>(a: T, opts?: PaymentOpts) => T;
|
|
98
|
-
export interface PaymentOpts {
|
|
99
|
-
validate?: boolean;
|
|
100
|
-
allowIncomplete?: boolean;
|
|
101
|
-
}
|
|
102
|
-
export type StackElement = Buffer | number;
|
|
103
|
-
export type Stack = StackElement[];
|
|
104
|
-
export type StackFunction = () => Stack;
|
|
1
|
+
export { PaymentType, type BasePayment, type ScriptRedeem, type P2PKPayment, type P2PKHPayment, type P2SHPayment, type P2MSPayment, type P2WPKHPayment, type P2WSHPayment, type P2TRPayment, type P2OPPayment, type P2OPPaymentParams, type EmbedPayment, type Payment, type PaymentCreator, type PaymentOpts, } from './types.js';
|
|
2
|
+
export { p2data } from './embed.js';
|
|
3
|
+
export { prop, value } from './lazy.js';
|
|
4
|
+
export { p2ms } from './p2ms.js';
|
|
5
|
+
export { p2pk } from './p2pk.js';
|
|
6
|
+
export { p2pkh } from './p2pkh.js';
|
|
7
|
+
export { p2sh } from './p2sh.js';
|
|
8
|
+
export { p2tr } from './p2tr.js';
|
|
9
|
+
export { p2wpkh } from './p2wpkh.js';
|
|
10
|
+
export { p2wsh } from './p2wsh.js';
|
|
11
|
+
export { p2op } from './p2op.js';
|
|
12
|
+
export { findScriptPath, LEAF_VERSION_TAPSCRIPT, MAX_TAPTREE_DEPTH, rootHashFromPath, tapleafHash, toHashTree, tweakKey, type HashTree, } from './bip341.js';
|
package/build/payments/index.js
CHANGED
|
@@ -1,24 +1,12 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
(function (PaymentType) {
|
|
14
|
-
PaymentType["P2PK"] = "p2pk";
|
|
15
|
-
PaymentType["P2PKH"] = "p2pkh";
|
|
16
|
-
PaymentType["P2SH"] = "p2sh";
|
|
17
|
-
PaymentType["P2MS"] = "p2ms";
|
|
18
|
-
PaymentType["P2WPKH"] = "p2wpkh";
|
|
19
|
-
PaymentType["P2WSH"] = "p2wsh";
|
|
20
|
-
PaymentType["P2TR"] = "p2tr";
|
|
21
|
-
PaymentType["P2OP"] = "p2op";
|
|
22
|
-
PaymentType["Embed"] = "embed";
|
|
23
|
-
PaymentType["ScriptRedeem"] = "scriptRedeem";
|
|
24
|
-
})(PaymentType || (PaymentType = {}));
|
|
1
|
+
export { PaymentType, } from './types.js';
|
|
2
|
+
export { p2data } from './embed.js';
|
|
3
|
+
export { prop, value } from './lazy.js';
|
|
4
|
+
export { p2ms } from './p2ms.js';
|
|
5
|
+
export { p2pk } from './p2pk.js';
|
|
6
|
+
export { p2pkh } from './p2pkh.js';
|
|
7
|
+
export { p2sh } from './p2sh.js';
|
|
8
|
+
export { p2tr } from './p2tr.js';
|
|
9
|
+
export { p2wpkh } from './p2wpkh.js';
|
|
10
|
+
export { p2wsh } from './p2wsh.js';
|
|
11
|
+
export { p2op } from './p2op.js';
|
|
12
|
+
export { findScriptPath, LEAF_VERSION_TAPSCRIPT, MAX_TAPTREE_DEPTH, rootHashFromPath, tapleafHash, toHashTree, tweakKey, } from './bip341.js';
|
package/build/payments/p2ms.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { P2MSPayment, PaymentOpts } from './
|
|
1
|
+
import { P2MSPayment, PaymentOpts } from './types.js';
|
|
2
2
|
export declare function p2ms(a: Omit<P2MSPayment, 'name'>, opts?: PaymentOpts): P2MSPayment;
|
package/build/payments/p2ms.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { bitcoin as BITCOIN_NETWORK } from '../networks.js';
|
|
2
2
|
import * as bscript from '../script.js';
|
|
3
3
|
import { isPoint, stacksEqual, typeforce as typef } from '../types.js';
|
|
4
|
-
import { PaymentType } from './
|
|
4
|
+
import { PaymentType } from './types.js';
|
|
5
5
|
import * as lazy from './lazy.js';
|
|
6
6
|
const OPS = bscript.opcodes;
|
|
7
7
|
const OP_INT_BASE = OPS.OP_RESERVED;
|
package/build/payments/p2op.d.ts
CHANGED
package/build/payments/p2op.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { bech32m } from 'bech32';
|
|
2
2
|
import { Buffer as NBuffer } from 'buffer';
|
|
3
|
-
import { fromBech32 } from '../
|
|
3
|
+
import { fromBech32 } from '../bech32utils.js';
|
|
4
4
|
import { bitcoin as BITCOIN_NETWORK } from '../networks.js';
|
|
5
5
|
import * as bscript from '../script.js';
|
|
6
6
|
import { typeforce as typef } from '../types.js';
|
|
7
|
+
import { PaymentType } from './types.js';
|
|
7
8
|
import * as lazy from './lazy.js';
|
|
8
|
-
import { PaymentType } from './index.js';
|
|
9
9
|
const OPS = bscript.opcodes;
|
|
10
10
|
const P2OP_WITNESS_VERSION = 0x10;
|
|
11
11
|
const MIN_SIZE = 2;
|
package/build/payments/p2pk.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { P2PKPayment, PaymentOpts } from './
|
|
1
|
+
import { P2PKPayment, PaymentOpts } from './types.js';
|
|
2
2
|
export declare function p2pk(a: Omit<P2PKPayment, 'name'>, opts?: PaymentOpts): P2PKPayment;
|
package/build/payments/p2pk.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { bitcoin as BITCOIN_NETWORK } from '../networks.js';
|
|
2
2
|
import * as bscript from '../script.js';
|
|
3
3
|
import { isPoint, typeforce as typef } from '../types.js';
|
|
4
|
-
import { PaymentType } from './
|
|
4
|
+
import { PaymentType } from './types.js';
|
|
5
5
|
import * as lazy from './lazy.js';
|
|
6
6
|
const OPS = bscript.opcodes;
|
|
7
7
|
export function p2pk(a, opts) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { P2PKHPayment, PaymentOpts } from './
|
|
1
|
+
import { P2PKHPayment, PaymentOpts } from './types.js';
|
|
2
2
|
export declare function p2pkh(a: Omit<P2PKHPayment, 'name'>, opts?: PaymentOpts): P2PKHPayment;
|
package/build/payments/p2pkh.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as bs58check from 'bs58check';
|
|
2
2
|
import * as bcrypto from '../crypto.js';
|
|
3
3
|
import { bitcoin as BITCOIN_NETWORK } from '../networks.js';
|
|
4
|
+
import { decompressPublicKey } from '../pubkey.js';
|
|
4
5
|
import * as bscript from '../script.js';
|
|
5
6
|
import { isPoint, typeforce as typef } from '../types.js';
|
|
6
|
-
import { PaymentType } from './
|
|
7
|
+
import { PaymentType } from './types.js';
|
|
7
8
|
import * as lazy from './lazy.js';
|
|
8
|
-
import { decompressPublicKey } from '../psbt/psbtutils.js';
|
|
9
9
|
const OPS = bscript.opcodes;
|
|
10
10
|
export function p2pkh(a, opts) {
|
|
11
11
|
if (!a.address && !a.hash && !a.output && !a.pubkey && !a.input) {
|
package/build/payments/p2sh.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { P2SHPayment, PaymentOpts } from './
|
|
1
|
+
import { P2SHPayment, PaymentOpts } from './types.js';
|
|
2
2
|
export declare function p2sh(a: Omit<P2SHPayment, 'name'>, opts?: PaymentOpts): P2SHPayment;
|
package/build/payments/p2sh.js
CHANGED
|
@@ -3,7 +3,7 @@ import * as bcrypto from '../crypto.js';
|
|
|
3
3
|
import { bitcoin as BITCOIN_NETWORK } from '../networks.js';
|
|
4
4
|
import * as bscript from '../script.js';
|
|
5
5
|
import { stacksEqual, typeforce as typef } from '../types.js';
|
|
6
|
-
import { PaymentType
|
|
6
|
+
import { PaymentType } from './types.js';
|
|
7
7
|
import * as lazy from './lazy.js';
|
|
8
8
|
const OPS = bscript.opcodes;
|
|
9
9
|
export function p2sh(a, opts) {
|
package/build/payments/p2tr.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { P2TRPayment, PaymentOpts } from './
|
|
1
|
+
import { P2TRPayment, PaymentOpts } from './types.js';
|
|
2
2
|
export declare function p2tr(a: Omit<P2TRPayment, 'name'>, opts?: PaymentOpts): P2TRPayment;
|
package/build/payments/p2tr.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { bech32m } from 'bech32';
|
|
2
2
|
import { Buffer as NBuffer } from 'buffer';
|
|
3
|
-
import { fromBech32 } from '../
|
|
3
|
+
import { fromBech32 } from '../bech32utils.js';
|
|
4
4
|
import { getEccLib } from '../ecc_lib.js';
|
|
5
5
|
import { bitcoin as BITCOIN_NETWORK } from '../networks.js';
|
|
6
6
|
import * as bscript from '../script.js';
|
|
7
7
|
import { isTaptree, stacksEqual, TAPLEAF_VERSION_MASK, typeforce as typef } from '../types.js';
|
|
8
8
|
import { findScriptPath, LEAF_VERSION_TAPSCRIPT, rootHashFromPath, tapleafHash, toHashTree, tweakKey, } from './bip341.js';
|
|
9
|
-
import { PaymentType } from './
|
|
9
|
+
import { PaymentType } from './types.js';
|
|
10
10
|
import * as lazy from './lazy.js';
|
|
11
11
|
const OPS = bscript.opcodes;
|
|
12
12
|
const TAPROOT_WITNESS_VERSION = 0x01;
|
|
@@ -188,10 +188,6 @@ export function p2tr(a, opts) {
|
|
|
188
188
|
else
|
|
189
189
|
pubkey = tweakedKey.x;
|
|
190
190
|
}
|
|
191
|
-
if (pubkey && pubkey.length) {
|
|
192
|
-
if (!getEccLib().isXOnlyPoint(pubkey))
|
|
193
|
-
throw new TypeError('Invalid pubkey for p2tr');
|
|
194
|
-
}
|
|
195
191
|
const hashTree = _hashTree();
|
|
196
192
|
if (a.hash && hashTree) {
|
|
197
193
|
if (!a.hash.equals(hashTree.hash))
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { P2WPKHPayment, PaymentOpts } from './
|
|
1
|
+
import { P2WPKHPayment, PaymentOpts } from './types.js';
|
|
2
2
|
export declare function p2wpkh(a: Omit<P2WPKHPayment, 'name'>, opts?: PaymentOpts): P2WPKHPayment;
|