@btc-vision/bitcoin 6.4.8 → 6.4.10

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 (43) hide show
  1. package/browser/index.d.ts +1 -1
  2. package/browser/index.js +1 -1
  3. package/browser/opcodes.d.ts +125 -0
  4. package/browser/script.d.ts +2 -2
  5. package/build/address.js +6 -5
  6. package/build/bufferutils.js +1 -1
  7. package/build/index.d.ts +1 -1
  8. package/build/index.js +1 -1
  9. package/build/opcodes.d.ts +125 -0
  10. package/build/opcodes.js +126 -0
  11. package/build/payments/embed.js +1 -1
  12. package/build/payments/p2ms.js +1 -1
  13. package/build/payments/p2op.js +1 -1
  14. package/build/payments/p2pk.js +1 -1
  15. package/build/payments/p2pkh.js +1 -1
  16. package/build/payments/p2sh.js +3 -3
  17. package/build/payments/p2tr.js +1 -1
  18. package/build/payments/p2wpkh.js +2 -2
  19. package/build/payments/p2wsh.js +2 -2
  20. package/build/psbt.js +2 -2
  21. package/build/push_data.js +9 -9
  22. package/build/script.d.ts +2 -2
  23. package/build/script.js +12 -12
  24. package/build/transaction.js +1 -1
  25. package/package.json +1 -1
  26. package/src/address.ts +304 -303
  27. package/src/bufferutils.ts +1 -1
  28. package/src/index.ts +1 -1
  29. package/src/{ops.ts → opcodes.ts} +4 -6
  30. package/src/payments/embed.ts +1 -1
  31. package/src/payments/p2ms.ts +1 -1
  32. package/src/payments/p2op.ts +1 -1
  33. package/src/payments/p2pk.ts +1 -1
  34. package/src/payments/p2pkh.ts +1 -1
  35. package/src/payments/p2sh.ts +210 -210
  36. package/src/payments/p2tr.ts +1 -1
  37. package/src/payments/p2wpkh.ts +144 -144
  38. package/src/payments/p2wsh.ts +217 -217
  39. package/src/psbt.ts +2 -2
  40. package/src/push_data.ts +9 -9
  41. package/src/script.ts +12 -12
  42. package/src/transaction.ts +1 -1
  43. package/test/script.spec.ts +1 -1
@@ -0,0 +1,125 @@
1
+ export interface Opcodes {
2
+ OP_FALSE: number;
3
+ OP_0: number;
4
+ OP_PUSHDATA1: number;
5
+ OP_PUSHDATA2: number;
6
+ OP_PUSHDATA4: number;
7
+ OP_1NEGATE: number;
8
+ OP_RESERVED: number;
9
+ OP_TRUE: number;
10
+ OP_1: number;
11
+ OP_2: number;
12
+ OP_3: number;
13
+ OP_4: number;
14
+ OP_5: number;
15
+ OP_6: number;
16
+ OP_7: number;
17
+ OP_8: number;
18
+ OP_9: number;
19
+ OP_10: number;
20
+ OP_11: number;
21
+ OP_12: number;
22
+ OP_13: number;
23
+ OP_14: number;
24
+ OP_15: number;
25
+ OP_16: number;
26
+ OP_NOP: number;
27
+ OP_VER: number;
28
+ OP_IF: number;
29
+ OP_NOTIF: number;
30
+ OP_VERIF: number;
31
+ OP_VERNOTIF: number;
32
+ OP_ELSE: number;
33
+ OP_ENDIF: number;
34
+ OP_VERIFY: number;
35
+ OP_RETURN: number;
36
+ OP_TOALTSTACK: number;
37
+ OP_FROMALTSTACK: number;
38
+ OP_2DROP: number;
39
+ OP_2DUP: number;
40
+ OP_3DUP: number;
41
+ OP_2OVER: number;
42
+ OP_2ROT: number;
43
+ OP_2SWAP: number;
44
+ OP_IFDUP: number;
45
+ OP_DEPTH: number;
46
+ OP_DROP: number;
47
+ OP_DUP: number;
48
+ OP_NIP: number;
49
+ OP_OVER: number;
50
+ OP_PICK: number;
51
+ OP_ROLL: number;
52
+ OP_ROT: number;
53
+ OP_SWAP: number;
54
+ OP_TUCK: number;
55
+ OP_CAT: number;
56
+ OP_SUBSTR: number;
57
+ OP_LEFT: number;
58
+ OP_RIGHT: number;
59
+ OP_SIZE: number;
60
+ OP_INVERT: number;
61
+ OP_AND: number;
62
+ OP_OR: number;
63
+ OP_XOR: number;
64
+ OP_EQUAL: number;
65
+ OP_EQUALVERIFY: number;
66
+ OP_RESERVED1: number;
67
+ OP_RESERVED2: number;
68
+ OP_1ADD: number;
69
+ OP_1SUB: number;
70
+ OP_2MUL: number;
71
+ OP_2DIV: number;
72
+ OP_NEGATE: number;
73
+ OP_ABS: number;
74
+ OP_NOT: number;
75
+ OP_0NOTEQUAL: number;
76
+ OP_ADD: number;
77
+ OP_SUB: number;
78
+ OP_MUL: number;
79
+ OP_DIV: number;
80
+ OP_MOD: number;
81
+ OP_LSHIFT: number;
82
+ OP_RSHIFT: number;
83
+ OP_BOOLAND: number;
84
+ OP_BOOLOR: number;
85
+ OP_NUMEQUAL: number;
86
+ OP_NUMEQUALVERIFY: number;
87
+ OP_NUMNOTEQUAL: number;
88
+ OP_LESSTHAN: number;
89
+ OP_GREATERTHAN: number;
90
+ OP_LESSTHANOREQUAL: number;
91
+ OP_GREATERTHANOREQUAL: number;
92
+ OP_MIN: number;
93
+ OP_MAX: number;
94
+ OP_WITHIN: number;
95
+ OP_RIPEMD160: number;
96
+ OP_SHA1: number;
97
+ OP_SHA256: number;
98
+ OP_HASH160: number;
99
+ OP_HASH256: number;
100
+ OP_CODESEPARATOR: number;
101
+ OP_CHECKSIG: number;
102
+ OP_CHECKSIGVERIFY: number;
103
+ OP_CHECKMULTISIG: number;
104
+ OP_CHECKMULTISIGVERIFY: number;
105
+ OP_CHECKLOCKTIMEVERIFY: number;
106
+ OP_CHECKSEQUENCEVERIFY: number;
107
+ OP_CHECKSIGADD: number;
108
+ OP_NOP1: number;
109
+ OP_NOP2: number;
110
+ OP_NOP3: number;
111
+ OP_NOP4: number;
112
+ OP_NOP5: number;
113
+ OP_NOP6: number;
114
+ OP_NOP7: number;
115
+ OP_NOP8: number;
116
+ OP_NOP9: number;
117
+ OP_NOP10: number;
118
+ OP_PUBKEYHASH: number;
119
+ OP_PUBKEY: number;
120
+ OP_INVALIDOPCODE: number;
121
+ }
122
+ export declare const opcodes: Opcodes;
123
+ export declare const REVERSE_OPS: {
124
+ [key: number]: string;
125
+ };
@@ -1,8 +1,8 @@
1
- import { OPS } from './ops.js';
1
+ import { opcodes } from './opcodes.js';
2
2
  import { Stack } from './payments/index.js';
3
3
  import * as scriptNumber from './script_number.js';
4
4
  import * as scriptSignature from './script_signature.js';
5
- export { OPS };
5
+ export { opcodes };
6
6
  export declare function isPushOnly(value: Stack): boolean;
7
7
  export declare function countNonPushOnlyOPs(value: Stack): number;
8
8
  export declare function compile(chunks: Buffer | Stack): Buffer;
package/build/address.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import { bech32, bech32m } from 'bech32';
2
2
  import * as bs58check from 'bs58check';
3
- import { opcodes, payments } from './index.js';
4
3
  import * as networks from './networks.js';
5
4
  import * as bscript from './script.js';
5
+ import { opcodes } from './script.js';
6
6
  import { Hash160bit, tuple, typeforce, UInt8 } from './types.js';
7
+ import { payments } from './index.js';
7
8
  export const FUTURE_SEGWIT_MAX_SIZE = 40;
8
9
  export const FUTURE_SEGWIT_MIN_SIZE = 2;
9
10
  export const FUTURE_SEGWIT_MAX_VERSION = 15;
@@ -17,7 +18,7 @@ const FUTURE_SEGWIT_VERSION_WARNING = 'WARNING: Sending to a future segwit versi
17
18
  'then decide when it is safe to use which version of segwit.';
18
19
  export const isUnknownSegwitVersion = (output) => {
19
20
  try {
20
- const data = output.subarray(2);
21
+ const data = Buffer.from(output.subarray(2));
21
22
  if (data.length < FUTURE_SEGWIT_MIN_SIZE || data.length > FUTURE_SEGWIT_MAX_SIZE) {
22
23
  throw new TypeError('Invalid program length for segwit address');
23
24
  }
@@ -50,7 +51,7 @@ export function toFutureOPNetAddress(output, network) {
50
51
  else {
51
52
  throw new TypeError('Unsupported push opcode in script');
52
53
  }
53
- const program = output.subarray(pushPos, pushPos + progLen);
54
+ const program = Buffer.from(output.subarray(pushPos, pushPos + progLen));
54
55
  if (program.length < FUTURE_SEGWIT_MIN_SIZE || program.length > FUTURE_SEGWIT_MAX_SIZE)
55
56
  throw new TypeError('Invalid program length for segwit address');
56
57
  const version = opcode === opcodes.OP_0
@@ -64,7 +65,7 @@ export function toFutureOPNetAddress(output, network) {
64
65
  return bech32m.encode(network.bech32Opnet, words);
65
66
  }
66
67
  export function _toFutureSegwitAddress(output, network) {
67
- const data = output.subarray(2);
68
+ const data = Buffer.from(output.subarray(2));
68
69
  if (data.length < FUTURE_SEGWIT_MIN_SIZE || data.length > FUTURE_SEGWIT_MAX_SIZE) {
69
70
  throw new TypeError('Invalid program length for segwit address');
70
71
  }
@@ -84,7 +85,7 @@ export function fromBase58Check(address) {
84
85
  if (payload.length > 21)
85
86
  throw new TypeError(address + ' is too long');
86
87
  const version = payload.readUInt8(0);
87
- const hash = payload.subarray(1);
88
+ const hash = Buffer.from(payload.subarray(1));
88
89
  return { version, hash };
89
90
  }
90
91
  export function fromBech32(address) {
@@ -124,7 +124,7 @@ export class BufferReader {
124
124
  if (this.buffer.length < this.offset + n) {
125
125
  throw new Error('Cannot read slice out of bounds');
126
126
  }
127
- const result = this.buffer.subarray(this.offset, this.offset + n);
127
+ const result = Buffer.from(this.buffer.subarray(this.offset, this.offset + n));
128
128
  this.offset += n;
129
129
  return result;
130
130
  }
package/build/index.d.ts CHANGED
@@ -13,7 +13,7 @@ export * as script from './script.js';
13
13
  export { Block } from './block.js';
14
14
  export * from './crypto.js';
15
15
  export * from './psbt.js';
16
- export { OPS as opcodes } from './ops.js';
16
+ export { opcodes } from './opcodes.js';
17
17
  export { Transaction } from './transaction.js';
18
18
  export { Network } from './networks.js';
19
19
  export { initEccLib } from './ecc_lib.js';
package/build/index.js CHANGED
@@ -12,7 +12,7 @@ export * as script from './script.js';
12
12
  export { Block } from './block.js';
13
13
  export * from './crypto.js';
14
14
  export * from './psbt.js';
15
- export { OPS as opcodes } from './ops.js';
15
+ export { opcodes } from './opcodes.js';
16
16
  export { Transaction } from './transaction.js';
17
17
  export { initEccLib } from './ecc_lib.js';
18
18
  export { PaymentType, } from './payments/index.js';
@@ -0,0 +1,125 @@
1
+ export interface Opcodes {
2
+ OP_FALSE: number;
3
+ OP_0: number;
4
+ OP_PUSHDATA1: number;
5
+ OP_PUSHDATA2: number;
6
+ OP_PUSHDATA4: number;
7
+ OP_1NEGATE: number;
8
+ OP_RESERVED: number;
9
+ OP_TRUE: number;
10
+ OP_1: number;
11
+ OP_2: number;
12
+ OP_3: number;
13
+ OP_4: number;
14
+ OP_5: number;
15
+ OP_6: number;
16
+ OP_7: number;
17
+ OP_8: number;
18
+ OP_9: number;
19
+ OP_10: number;
20
+ OP_11: number;
21
+ OP_12: number;
22
+ OP_13: number;
23
+ OP_14: number;
24
+ OP_15: number;
25
+ OP_16: number;
26
+ OP_NOP: number;
27
+ OP_VER: number;
28
+ OP_IF: number;
29
+ OP_NOTIF: number;
30
+ OP_VERIF: number;
31
+ OP_VERNOTIF: number;
32
+ OP_ELSE: number;
33
+ OP_ENDIF: number;
34
+ OP_VERIFY: number;
35
+ OP_RETURN: number;
36
+ OP_TOALTSTACK: number;
37
+ OP_FROMALTSTACK: number;
38
+ OP_2DROP: number;
39
+ OP_2DUP: number;
40
+ OP_3DUP: number;
41
+ OP_2OVER: number;
42
+ OP_2ROT: number;
43
+ OP_2SWAP: number;
44
+ OP_IFDUP: number;
45
+ OP_DEPTH: number;
46
+ OP_DROP: number;
47
+ OP_DUP: number;
48
+ OP_NIP: number;
49
+ OP_OVER: number;
50
+ OP_PICK: number;
51
+ OP_ROLL: number;
52
+ OP_ROT: number;
53
+ OP_SWAP: number;
54
+ OP_TUCK: number;
55
+ OP_CAT: number;
56
+ OP_SUBSTR: number;
57
+ OP_LEFT: number;
58
+ OP_RIGHT: number;
59
+ OP_SIZE: number;
60
+ OP_INVERT: number;
61
+ OP_AND: number;
62
+ OP_OR: number;
63
+ OP_XOR: number;
64
+ OP_EQUAL: number;
65
+ OP_EQUALVERIFY: number;
66
+ OP_RESERVED1: number;
67
+ OP_RESERVED2: number;
68
+ OP_1ADD: number;
69
+ OP_1SUB: number;
70
+ OP_2MUL: number;
71
+ OP_2DIV: number;
72
+ OP_NEGATE: number;
73
+ OP_ABS: number;
74
+ OP_NOT: number;
75
+ OP_0NOTEQUAL: number;
76
+ OP_ADD: number;
77
+ OP_SUB: number;
78
+ OP_MUL: number;
79
+ OP_DIV: number;
80
+ OP_MOD: number;
81
+ OP_LSHIFT: number;
82
+ OP_RSHIFT: number;
83
+ OP_BOOLAND: number;
84
+ OP_BOOLOR: number;
85
+ OP_NUMEQUAL: number;
86
+ OP_NUMEQUALVERIFY: number;
87
+ OP_NUMNOTEQUAL: number;
88
+ OP_LESSTHAN: number;
89
+ OP_GREATERTHAN: number;
90
+ OP_LESSTHANOREQUAL: number;
91
+ OP_GREATERTHANOREQUAL: number;
92
+ OP_MIN: number;
93
+ OP_MAX: number;
94
+ OP_WITHIN: number;
95
+ OP_RIPEMD160: number;
96
+ OP_SHA1: number;
97
+ OP_SHA256: number;
98
+ OP_HASH160: number;
99
+ OP_HASH256: number;
100
+ OP_CODESEPARATOR: number;
101
+ OP_CHECKSIG: number;
102
+ OP_CHECKSIGVERIFY: number;
103
+ OP_CHECKMULTISIG: number;
104
+ OP_CHECKMULTISIGVERIFY: number;
105
+ OP_CHECKLOCKTIMEVERIFY: number;
106
+ OP_CHECKSEQUENCEVERIFY: number;
107
+ OP_CHECKSIGADD: number;
108
+ OP_NOP1: number;
109
+ OP_NOP2: number;
110
+ OP_NOP3: number;
111
+ OP_NOP4: number;
112
+ OP_NOP5: number;
113
+ OP_NOP6: number;
114
+ OP_NOP7: number;
115
+ OP_NOP8: number;
116
+ OP_NOP9: number;
117
+ OP_NOP10: number;
118
+ OP_PUBKEYHASH: number;
119
+ OP_PUBKEY: number;
120
+ OP_INVALIDOPCODE: number;
121
+ }
122
+ export declare const opcodes: Opcodes;
123
+ export declare const REVERSE_OPS: {
124
+ [key: number]: string;
125
+ };
@@ -0,0 +1,126 @@
1
+ export const opcodes = {
2
+ OP_FALSE: 0,
3
+ OP_0: 0,
4
+ OP_PUSHDATA1: 76,
5
+ OP_PUSHDATA2: 77,
6
+ OP_PUSHDATA4: 78,
7
+ OP_1NEGATE: 79,
8
+ OP_RESERVED: 80,
9
+ OP_TRUE: 81,
10
+ OP_1: 81,
11
+ OP_2: 82,
12
+ OP_3: 83,
13
+ OP_4: 84,
14
+ OP_5: 85,
15
+ OP_6: 86,
16
+ OP_7: 87,
17
+ OP_8: 88,
18
+ OP_9: 89,
19
+ OP_10: 90,
20
+ OP_11: 91,
21
+ OP_12: 92,
22
+ OP_13: 93,
23
+ OP_14: 94,
24
+ OP_15: 95,
25
+ OP_16: 96,
26
+ OP_NOP: 97,
27
+ OP_VER: 98,
28
+ OP_IF: 99,
29
+ OP_NOTIF: 100,
30
+ OP_VERIF: 101,
31
+ OP_VERNOTIF: 102,
32
+ OP_ELSE: 103,
33
+ OP_ENDIF: 104,
34
+ OP_VERIFY: 105,
35
+ OP_RETURN: 106,
36
+ OP_TOALTSTACK: 107,
37
+ OP_FROMALTSTACK: 108,
38
+ OP_2DROP: 109,
39
+ OP_2DUP: 110,
40
+ OP_3DUP: 111,
41
+ OP_2OVER: 112,
42
+ OP_2ROT: 113,
43
+ OP_2SWAP: 114,
44
+ OP_IFDUP: 115,
45
+ OP_DEPTH: 116,
46
+ OP_DROP: 117,
47
+ OP_DUP: 118,
48
+ OP_NIP: 119,
49
+ OP_OVER: 120,
50
+ OP_PICK: 121,
51
+ OP_ROLL: 122,
52
+ OP_ROT: 123,
53
+ OP_SWAP: 124,
54
+ OP_TUCK: 125,
55
+ OP_CAT: 126,
56
+ OP_SUBSTR: 127,
57
+ OP_LEFT: 128,
58
+ OP_RIGHT: 129,
59
+ OP_SIZE: 130,
60
+ OP_INVERT: 131,
61
+ OP_AND: 132,
62
+ OP_OR: 133,
63
+ OP_XOR: 134,
64
+ OP_EQUAL: 135,
65
+ OP_EQUALVERIFY: 136,
66
+ OP_RESERVED1: 137,
67
+ OP_RESERVED2: 138,
68
+ OP_1ADD: 139,
69
+ OP_1SUB: 140,
70
+ OP_2MUL: 141,
71
+ OP_2DIV: 142,
72
+ OP_NEGATE: 143,
73
+ OP_ABS: 144,
74
+ OP_NOT: 145,
75
+ OP_0NOTEQUAL: 146,
76
+ OP_ADD: 147,
77
+ OP_SUB: 148,
78
+ OP_MUL: 149,
79
+ OP_DIV: 150,
80
+ OP_MOD: 151,
81
+ OP_LSHIFT: 152,
82
+ OP_RSHIFT: 153,
83
+ OP_BOOLAND: 154,
84
+ OP_BOOLOR: 155,
85
+ OP_NUMEQUAL: 156,
86
+ OP_NUMEQUALVERIFY: 157,
87
+ OP_NUMNOTEQUAL: 158,
88
+ OP_LESSTHAN: 159,
89
+ OP_GREATERTHAN: 160,
90
+ OP_LESSTHANOREQUAL: 161,
91
+ OP_GREATERTHANOREQUAL: 162,
92
+ OP_MIN: 163,
93
+ OP_MAX: 164,
94
+ OP_WITHIN: 165,
95
+ OP_RIPEMD160: 166,
96
+ OP_SHA1: 167,
97
+ OP_SHA256: 168,
98
+ OP_HASH160: 169,
99
+ OP_HASH256: 170,
100
+ OP_CODESEPARATOR: 171,
101
+ OP_CHECKSIG: 172,
102
+ OP_CHECKSIGVERIFY: 173,
103
+ OP_CHECKMULTISIG: 174,
104
+ OP_CHECKMULTISIGVERIFY: 175,
105
+ OP_NOP1: 176,
106
+ OP_NOP2: 177,
107
+ OP_CHECKLOCKTIMEVERIFY: 177,
108
+ OP_NOP3: 178,
109
+ OP_CHECKSEQUENCEVERIFY: 178,
110
+ OP_NOP4: 179,
111
+ OP_NOP5: 180,
112
+ OP_NOP6: 181,
113
+ OP_NOP7: 182,
114
+ OP_NOP8: 183,
115
+ OP_NOP9: 184,
116
+ OP_NOP10: 185,
117
+ OP_CHECKSIGADD: 186,
118
+ OP_PUBKEYHASH: 253,
119
+ OP_PUBKEY: 254,
120
+ OP_INVALIDOPCODE: 255,
121
+ };
122
+ export const REVERSE_OPS = {};
123
+ for (const op of Object.keys(opcodes)) {
124
+ const code = opcodes[op];
125
+ REVERSE_OPS[code] = op;
126
+ }
@@ -3,7 +3,7 @@ import * as bscript from '../script.js';
3
3
  import { stacksEqual, typeforce as typef } from '../types.js';
4
4
  import { PaymentType } from './index.js';
5
5
  import * as lazy from './lazy.js';
6
- const OPS = bscript.OPS;
6
+ const OPS = bscript.opcodes;
7
7
  export function p2data(a, opts) {
8
8
  if (!a.data && !a.output)
9
9
  throw new TypeError('Not enough data');
@@ -3,7 +3,7 @@ import * as bscript from '../script.js';
3
3
  import { isPoint, stacksEqual, typeforce as typef } from '../types.js';
4
4
  import { PaymentType } from './index.js';
5
5
  import * as lazy from './lazy.js';
6
- const OPS = bscript.OPS;
6
+ const OPS = bscript.opcodes;
7
7
  const OP_INT_BASE = OPS.OP_RESERVED;
8
8
  export function p2ms(a, opts) {
9
9
  if (!a.input && !a.output && !(a.pubkeys && a.m !== undefined) && !a.signatures)
@@ -6,7 +6,7 @@ import * as bscript from '../script.js';
6
6
  import { typeforce as typef } from '../types.js';
7
7
  import * as lazy from './lazy.js';
8
8
  import { PaymentType } from './index.js';
9
- const OPS = bscript.OPS;
9
+ const OPS = bscript.opcodes;
10
10
  const P2OP_WITNESS_VERSION = 0x10;
11
11
  const MIN_SIZE = 2;
12
12
  const MAX_SIZE = 40;
@@ -3,7 +3,7 @@ import * as bscript from '../script.js';
3
3
  import { isPoint, typeforce as typef } from '../types.js';
4
4
  import { PaymentType } from './index.js';
5
5
  import * as lazy from './lazy.js';
6
- const OPS = bscript.OPS;
6
+ const OPS = bscript.opcodes;
7
7
  export function p2pk(a, opts) {
8
8
  if (!a.input && !a.output && !a.pubkey && !a.input && !a.signature)
9
9
  throw new TypeError('Not enough data');
@@ -6,7 +6,7 @@ import { isPoint, typeforce as typef } from '../types.js';
6
6
  import { PaymentType } from './index.js';
7
7
  import * as lazy from './lazy.js';
8
8
  import { decompressPublicKey } from '../psbt/psbtutils.js';
9
- const OPS = bscript.OPS;
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) {
12
12
  throw new TypeError('Not enough data');
@@ -3,9 +3,9 @@ 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 './index.js';
7
7
  import * as lazy from './lazy.js';
8
- const OPS = bscript.OPS;
8
+ const OPS = bscript.opcodes;
9
9
  export function p2sh(a, opts) {
10
10
  if (!a.address && !a.hash && !a.output && !a.redeem && !a.input) {
11
11
  throw new TypeError('Not enough data');
@@ -31,7 +31,7 @@ export function p2sh(a, opts) {
31
31
  }
32
32
  const o = {
33
33
  network,
34
- name: PaymentType.P2SH
34
+ name: PaymentType.P2SH,
35
35
  };
36
36
  const _address = lazy.value(() => {
37
37
  const payload = Buffer.from(bs58check.default.decode(a.address));
@@ -8,7 +8,7 @@ import { isTaptree, stacksEqual, TAPLEAF_VERSION_MASK, typeforce as typef } from
8
8
  import { findScriptPath, LEAF_VERSION_TAPSCRIPT, rootHashFromPath, tapleafHash, toHashTree, tweakKey, } from './bip341.js';
9
9
  import { PaymentType } from './index.js';
10
10
  import * as lazy from './lazy.js';
11
- const OPS = bscript.OPS;
11
+ const OPS = bscript.opcodes;
12
12
  const TAPROOT_WITNESS_VERSION = 0x01;
13
13
  const ANNEX_PREFIX = 0x50;
14
14
  export function p2tr(a, opts) {
@@ -5,7 +5,7 @@ import * as bscript from '../script.js';
5
5
  import { isPoint, typeforce as typef } from '../types.js';
6
6
  import { PaymentType } from './index.js';
7
7
  import * as lazy from './lazy.js';
8
- const OPS = bscript.OPS;
8
+ const OPS = bscript.opcodes;
9
9
  const EMPTY_BUFFER = Buffer.alloc(0);
10
10
  export function p2wpkh(a, opts) {
11
11
  if (!a.address && !a.hash && !a.output && !a.pubkey && !a.witness)
@@ -34,7 +34,7 @@ export function p2wpkh(a, opts) {
34
34
  const network = a.network || BITCOIN_NETWORK;
35
35
  const o = {
36
36
  name: PaymentType.P2WPKH,
37
- network
37
+ network,
38
38
  };
39
39
  lazy.prop(o, 'address', () => {
40
40
  if (!o.hash)
@@ -5,7 +5,7 @@ import * as bscript from '../script.js';
5
5
  import { isPoint, stacksEqual, typeforce as typef } from '../types.js';
6
6
  import { PaymentType } from './index.js';
7
7
  import * as lazy from './lazy.js';
8
- const OPS = bscript.OPS;
8
+ const OPS = bscript.opcodes;
9
9
  const EMPTY_BUFFER = Buffer.alloc(0);
10
10
  function chunkHasUncompressedPubkey(chunk) {
11
11
  if (Buffer.isBuffer(chunk) && chunk.length === 65 && chunk[0] === 0x04 && isPoint(chunk)) {
@@ -52,7 +52,7 @@ export function p2wsh(a, opts) {
52
52
  }
53
53
  const o = {
54
54
  network,
55
- name: PaymentType.P2WSH
55
+ name: PaymentType.P2WSH,
56
56
  };
57
57
  lazy.prop(o, 'address', () => {
58
58
  if (!o.hash)
package/build/psbt.js CHANGED
@@ -948,10 +948,10 @@ function getAllTaprootHashesForSig(inputIndex, input, inputs, cache) {
948
948
  }
949
949
  function getPrevoutTaprootKey(inputIndex, input, cache) {
950
950
  const { script } = getScriptAndAmountFromUtxo(inputIndex, input, cache);
951
- return isP2TR(script) ? script.subarray(2, 34) : null;
951
+ return isP2TR(script) ? Buffer.from(script.subarray(2, 34)) : null;
952
952
  }
953
953
  function trimTaprootSig(signature) {
954
- return signature.length === 64 ? signature : signature.subarray(0, 64);
954
+ return signature.length === 64 ? signature : Buffer.from(signature.subarray(0, 64));
955
955
  }
956
956
  function getTaprootHashesForSig(inputIndex, input, inputs, pubkey, cache, tapLeafHashToSign, allowedSighashTypes) {
957
957
  const unsignedTx = cache.__TX;
@@ -1,6 +1,6 @@
1
- import { OPS } from './ops.js';
1
+ import { opcodes } from './opcodes.js';
2
2
  export function encodingLength(i) {
3
- return i < OPS.OP_PUSHDATA1 ? 1 : i <= 0xff ? 2 : i <= 0xffff ? 3 : 5;
3
+ return i < opcodes.OP_PUSHDATA1 ? 1 : i <= 0xff ? 2 : i <= 0xffff ? 3 : 5;
4
4
  }
5
5
  export function encode(buffer, num, offset) {
6
6
  const size = encodingLength(num);
@@ -8,15 +8,15 @@ export function encode(buffer, num, offset) {
8
8
  buffer.writeUInt8(num, offset);
9
9
  }
10
10
  else if (size === 2) {
11
- buffer.writeUInt8(OPS.OP_PUSHDATA1, offset);
11
+ buffer.writeUInt8(opcodes.OP_PUSHDATA1, offset);
12
12
  buffer.writeUInt8(num, offset + 1);
13
13
  }
14
14
  else if (size === 3) {
15
- buffer.writeUInt8(OPS.OP_PUSHDATA2, offset);
15
+ buffer.writeUInt8(opcodes.OP_PUSHDATA2, offset);
16
16
  buffer.writeUInt16LE(num, offset + 1);
17
17
  }
18
18
  else {
19
- buffer.writeUInt8(OPS.OP_PUSHDATA4, offset);
19
+ buffer.writeUInt8(opcodes.OP_PUSHDATA4, offset);
20
20
  buffer.writeUInt32LE(num, offset + 1);
21
21
  }
22
22
  return size;
@@ -25,17 +25,17 @@ export function decode(buffer, offset) {
25
25
  const opcode = buffer.readUInt8(offset);
26
26
  let num;
27
27
  let size;
28
- if (opcode < OPS.OP_PUSHDATA1) {
28
+ if (opcode < opcodes.OP_PUSHDATA1) {
29
29
  num = opcode;
30
30
  size = 1;
31
31
  }
32
- else if (opcode === OPS.OP_PUSHDATA1) {
32
+ else if (opcode === opcodes.OP_PUSHDATA1) {
33
33
  if (offset + 2 > buffer.length)
34
34
  return null;
35
35
  num = buffer.readUInt8(offset + 1);
36
36
  size = 2;
37
37
  }
38
- else if (opcode === OPS.OP_PUSHDATA2) {
38
+ else if (opcode === opcodes.OP_PUSHDATA2) {
39
39
  if (offset + 3 > buffer.length)
40
40
  return null;
41
41
  num = buffer.readUInt16LE(offset + 1);
@@ -44,7 +44,7 @@ export function decode(buffer, offset) {
44
44
  else {
45
45
  if (offset + 5 > buffer.length)
46
46
  return null;
47
- if (opcode !== OPS.OP_PUSHDATA4)
47
+ if (opcode !== opcodes.OP_PUSHDATA4)
48
48
  throw new Error('Unexpected opcode');
49
49
  num = buffer.readUInt32LE(offset + 1);
50
50
  size = 5;
package/build/script.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { OPS } from './ops.js';
1
+ import { opcodes } from './opcodes.js';
2
2
  import { Stack } from './payments/index.js';
3
3
  import * as scriptNumber from './script_number.js';
4
4
  import * as scriptSignature from './script_signature.js';
5
- export { OPS };
5
+ export { opcodes };
6
6
  export declare function isPushOnly(value: Stack): boolean;
7
7
  export declare function countNonPushOnlyOPs(value: Stack): number;
8
8
  export declare function compile(chunks: Buffer | Stack): Buffer;