@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.
Files changed (93) hide show
  1. package/browser/address.d.ts +2 -6
  2. package/browser/bech32utils.d.ts +6 -0
  3. package/browser/chunks/{crypto-0PweVewC.js → crypto-BhCpKpek.js} +4 -4
  4. package/browser/chunks/{payments-CgasufRS.js → payments-yjA0Evsv.js} +639 -597
  5. package/browser/chunks/{psbt-BIwOrKer.js → psbt-URK2hBFc.js} +1259 -1316
  6. package/browser/chunks/{script-CROJPzz_.js → script-DyPItFEl.js} +33 -33
  7. package/browser/chunks/{transaction-DchBu35N.js → transaction-C_UbhMGn.js} +3 -3
  8. package/browser/chunks/{utils-CO5kmxe9.js → utils-DNZi-T5W.js} +26 -26
  9. package/browser/index.d.ts +3 -1
  10. package/browser/index.js +102 -90
  11. package/browser/payments/embed.d.ts +1 -1
  12. package/browser/payments/index.d.ts +12 -104
  13. package/browser/payments/p2ms.d.ts +1 -1
  14. package/browser/payments/p2op.d.ts +1 -1
  15. package/browser/payments/p2pk.d.ts +1 -1
  16. package/browser/payments/p2pkh.d.ts +1 -1
  17. package/browser/payments/p2sh.d.ts +1 -1
  18. package/browser/payments/p2tr.d.ts +1 -1
  19. package/browser/payments/p2wpkh.d.ts +1 -1
  20. package/browser/payments/p2wsh.d.ts +1 -1
  21. package/browser/payments/types.d.ts +93 -0
  22. package/browser/psbt/bip371.d.ts +0 -1
  23. package/browser/psbt/psbtutils.d.ts +0 -7
  24. package/browser/pubkey.d.ts +8 -0
  25. package/browser/script.d.ts +1 -2
  26. package/browser/script_signature.d.ts +1 -0
  27. package/browser/types.d.ts +3 -0
  28. package/build/address.d.ts +2 -6
  29. package/build/address.js +19 -37
  30. package/build/bech32utils.d.ts +6 -0
  31. package/build/bech32utils.js +26 -0
  32. package/build/index.d.ts +3 -1
  33. package/build/index.js +1 -0
  34. package/build/payments/embed.d.ts +1 -1
  35. package/build/payments/embed.js +1 -1
  36. package/build/payments/index.d.ts +12 -104
  37. package/build/payments/index.js +12 -24
  38. package/build/payments/p2ms.d.ts +1 -1
  39. package/build/payments/p2ms.js +1 -1
  40. package/build/payments/p2op.d.ts +1 -1
  41. package/build/payments/p2op.js +2 -2
  42. package/build/payments/p2pk.d.ts +1 -1
  43. package/build/payments/p2pk.js +1 -1
  44. package/build/payments/p2pkh.d.ts +1 -1
  45. package/build/payments/p2pkh.js +2 -2
  46. package/build/payments/p2sh.d.ts +1 -1
  47. package/build/payments/p2sh.js +1 -1
  48. package/build/payments/p2tr.d.ts +1 -1
  49. package/build/payments/p2tr.js +2 -6
  50. package/build/payments/p2wpkh.d.ts +1 -1
  51. package/build/payments/p2wpkh.js +1 -1
  52. package/build/payments/p2wsh.d.ts +1 -1
  53. package/build/payments/p2wsh.js +2 -2
  54. package/build/payments/types.d.ts +93 -0
  55. package/build/payments/types.js +13 -0
  56. package/build/psbt/bip371.d.ts +0 -1
  57. package/build/psbt/bip371.js +2 -6
  58. package/build/psbt/psbtutils.d.ts +0 -7
  59. package/build/psbt/psbtutils.js +2 -54
  60. package/build/psbt.js +3 -2
  61. package/build/pubkey.d.ts +8 -0
  62. package/build/pubkey.js +56 -0
  63. package/build/script.d.ts +1 -2
  64. package/build/script.js +1 -4
  65. package/build/script_signature.d.ts +1 -0
  66. package/build/script_signature.js +4 -1
  67. package/build/tsconfig.tsbuildinfo +1 -1
  68. package/build/types.d.ts +3 -0
  69. package/package.json +5 -2
  70. package/src/address.ts +20 -50
  71. package/src/bech32utils.ts +43 -0
  72. package/src/index.ts +2 -3
  73. package/src/payments/embed.ts +2 -2
  74. package/src/payments/index.ts +40 -164
  75. package/src/payments/p2ms.ts +2 -2
  76. package/src/payments/p2op.ts +2 -2
  77. package/src/payments/p2pk.ts +2 -2
  78. package/src/payments/p2pkh.ts +3 -3
  79. package/src/payments/p2sh.ts +2 -10
  80. package/src/payments/p2tr.ts +6 -5
  81. package/src/payments/p2wpkh.ts +1 -1
  82. package/src/payments/p2wsh.ts +8 -2
  83. package/src/payments/types.ts +154 -0
  84. package/src/psbt/bip371.ts +6 -13
  85. package/src/psbt/psbtutils.ts +2 -104
  86. package/src/psbt.ts +3 -2
  87. package/src/pubkey.ts +99 -0
  88. package/src/script.ts +2 -7
  89. package/src/script_signature.ts +10 -1
  90. package/src/types.ts +5 -0
  91. package/test/address.spec.ts +8 -7
  92. package/test/integration/taproot.spec.ts +2 -1
  93. 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
+ }
@@ -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;
@@ -1,5 +1,5 @@
1
1
  import { opcodes } from './opcodes.js';
2
- import { Stack } from './payments/index.js';
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;
@@ -1,3 +1,4 @@
1
+ export declare function isDefinedHashType(hashType: number): boolean;
1
2
  interface ScriptSignature {
2
3
  signature: Buffer;
3
4
  hashType: number;
@@ -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;
@@ -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
- import { payments } from './index.js';
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 payments.p2pkh({ output, network }).address;
116
+ return p2pkh({ output, network }).address;
135
117
  }
136
118
  catch (e) { }
137
119
  try {
138
- return payments.p2sh({ output, network }).address;
120
+ return p2sh({ output, network }).address;
139
121
  }
140
122
  catch (e) { }
141
123
  try {
142
- return payments.p2wpkh({ output, network }).address;
124
+ return p2wpkh({ output, network }).address;
143
125
  }
144
126
  catch (e) { }
145
127
  try {
146
- return payments.p2wsh({ output, network }).address;
128
+ return p2wsh({ output, network }).address;
147
129
  }
148
130
  catch (e) { }
149
131
  try {
150
- return payments.p2tr({ output, network }).address;
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 payments.p2pkh({ hash: decodeBase58.hash }).output;
155
+ return p2pkh({ hash: decodeBase58.hash }).output;
174
156
  if (decodeBase58.version === network.scriptHash)
175
- return payments.p2sh({ hash: decodeBase58.hash }).output;
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 payments.p2wpkh({ hash: decodeBech32.data }).output;
171
+ return p2wpkh({ hash: decodeBech32.data }).output;
190
172
  if (decodeBech32.data.length === 32)
191
- return payments.p2wsh({ hash: decodeBech32.data }).output;
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 payments.p2tr({ pubkey: decodeBech32.data }).output;
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 payments.p2op({
182
+ return p2op({
201
183
  program: decodeBech32.data,
202
184
  network,
203
185
  }).output;
@@ -0,0 +1,6 @@
1
+ export interface Bech32Result {
2
+ version: number;
3
+ prefix: string;
4
+ data: Buffer;
5
+ }
6
+ export declare function fromBech32(address: string): Bech32Result;
@@ -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, Stack, StackElement, P2WSHPayment, P2PKPayment, BasePayment, P2SHPayment, P2TRPayment, P2WPKHPayment, P2PKHPayment, P2MSPayment, EmbedPayment, P2OPPayment, P2OPPaymentParams, StackFunction, } from './payments/index.js';
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 './index.js';
1
+ import { EmbedPayment, PaymentOpts } from './types.js';
2
2
  export declare function p2data(a: Omit<EmbedPayment, 'name'>, opts?: PaymentOpts): EmbedPayment;
@@ -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 './index.js';
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
- import type { Network } from '../networks.js';
2
- import type { Taptree } from '../types.js';
3
- export * from './bip341.js';
4
- export * from './embed.js';
5
- export * from './lazy.js';
6
- export * from './p2ms.js';
7
- export * from './p2pk.js';
8
- export * from './p2pkh.js';
9
- export * from './p2sh.js';
10
- export * from './p2tr.js';
11
- export * from './p2wpkh.js';
12
- export * from './p2wsh.js';
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';
@@ -1,24 +1,12 @@
1
- export * from './bip341.js';
2
- export * from './embed.js';
3
- export * from './lazy.js';
4
- export * from './p2ms.js';
5
- export * from './p2pk.js';
6
- export * from './p2pkh.js';
7
- export * from './p2sh.js';
8
- export * from './p2tr.js';
9
- export * from './p2wpkh.js';
10
- export * from './p2wsh.js';
11
- export * from './p2op.js';
12
- export var PaymentType;
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';
@@ -1,2 +1,2 @@
1
- import { P2MSPayment, PaymentOpts } from './index.js';
1
+ import { P2MSPayment, PaymentOpts } from './types.js';
2
2
  export declare function p2ms(a: Omit<P2MSPayment, 'name'>, opts?: PaymentOpts): P2MSPayment;
@@ -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 './index.js';
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;
@@ -1,4 +1,4 @@
1
- import { BasePayment, P2OPPayment, PaymentOpts, PaymentType } from './index.js';
1
+ import { BasePayment, P2OPPayment, PaymentOpts, PaymentType } from './types.js';
2
2
  interface P2OPBase extends BasePayment {
3
3
  name: PaymentType.P2OP;
4
4
  }
@@ -1,11 +1,11 @@
1
1
  import { bech32m } from 'bech32';
2
2
  import { Buffer as NBuffer } from 'buffer';
3
- import { fromBech32 } from '../address.js';
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;
@@ -1,2 +1,2 @@
1
- import { P2PKPayment, PaymentOpts } from './index.js';
1
+ import { P2PKPayment, PaymentOpts } from './types.js';
2
2
  export declare function p2pk(a: Omit<P2PKPayment, 'name'>, opts?: PaymentOpts): P2PKPayment;
@@ -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 './index.js';
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 './index.js';
1
+ import { P2PKHPayment, PaymentOpts } from './types.js';
2
2
  export declare function p2pkh(a: Omit<P2PKHPayment, 'name'>, opts?: PaymentOpts): P2PKHPayment;
@@ -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 './index.js';
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) {
@@ -1,2 +1,2 @@
1
- import { P2SHPayment, PaymentOpts } from './index.js';
1
+ import { P2SHPayment, PaymentOpts } from './types.js';
2
2
  export declare function p2sh(a: Omit<P2SHPayment, 'name'>, opts?: PaymentOpts): P2SHPayment;
@@ -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, } from './index.js';
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) {
@@ -1,2 +1,2 @@
1
- import { P2TRPayment, PaymentOpts } from './index.js';
1
+ import { P2TRPayment, PaymentOpts } from './types.js';
2
2
  export declare function p2tr(a: Omit<P2TRPayment, 'name'>, opts?: PaymentOpts): P2TRPayment;
@@ -1,12 +1,12 @@
1
1
  import { bech32m } from 'bech32';
2
2
  import { Buffer as NBuffer } from 'buffer';
3
- import { fromBech32 } from '../address.js';
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 './index.js';
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 './index.js';
1
+ import { P2WPKHPayment, PaymentOpts } from './types.js';
2
2
  export declare function p2wpkh(a: Omit<P2WPKHPayment, 'name'>, opts?: PaymentOpts): P2WPKHPayment;