@btc-vision/bitcoin 6.4.9 → 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.
@@ -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;
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)
@@ -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;
package/build/script.js CHANGED
@@ -1,17 +1,17 @@
1
1
  import * as bip66 from './bip66.js';
2
- import { OPS, REVERSE_OPS } from './ops.js';
2
+ import { opcodes, REVERSE_OPS } from './opcodes.js';
3
3
  import * as pushdata from './push_data.js';
4
4
  import * as scriptNumber from './script_number.js';
5
5
  import * as scriptSignature from './script_signature.js';
6
6
  import * as types from './types.js';
7
7
  const { typeforce } = types;
8
- const OP_INT_BASE = OPS.OP_RESERVED;
9
- export { OPS };
8
+ const OP_INT_BASE = opcodes.OP_RESERVED;
9
+ export { opcodes };
10
10
  function isOPInt(value) {
11
11
  return (types.Number(value) &&
12
- (value === OPS.OP_0 ||
13
- (value >= OPS.OP_1 && value <= OPS.OP_16) ||
14
- value === OPS.OP_1NEGATE));
12
+ (value === opcodes.OP_0 ||
13
+ (value >= opcodes.OP_1 && value <= opcodes.OP_16) ||
14
+ value === opcodes.OP_1NEGATE));
15
15
  }
16
16
  function isPushOnlyChunk(value) {
17
17
  return types.Buffer(value) || isOPInt(value);
@@ -24,13 +24,13 @@ export function countNonPushOnlyOPs(value) {
24
24
  }
25
25
  function asMinimalOP(buffer) {
26
26
  if (buffer.length === 0)
27
- return OPS.OP_0;
27
+ return opcodes.OP_0;
28
28
  if (buffer.length !== 1)
29
29
  return;
30
30
  if (buffer[0] >= 1 && buffer[0] <= 16)
31
31
  return OP_INT_BASE + buffer[0];
32
32
  if (buffer[0] === 0x81)
33
- return OPS.OP_1NEGATE;
33
+ return opcodes.OP_1NEGATE;
34
34
  }
35
35
  function chunksIsBuffer(buf) {
36
36
  return Buffer.isBuffer(buf);
@@ -85,7 +85,7 @@ export function decompile(buffer) {
85
85
  let i = 0;
86
86
  while (i < buffer.length) {
87
87
  const opcode = buffer[i];
88
- if (opcode > OPS.OP_0 && opcode <= OPS.OP_PUSHDATA4) {
88
+ if (opcode > opcodes.OP_0 && opcode <= opcodes.OP_PUSHDATA4) {
89
89
  const d = pushdata.decode(buffer, i);
90
90
  if (d === null)
91
91
  return null;
@@ -131,8 +131,8 @@ export function toASM(chunks) {
131
131
  export function fromASM(asm) {
132
132
  typeforce(types.String, asm);
133
133
  return compile(asm.split(' ').map((chunkStr) => {
134
- if (OPS[chunkStr] !== undefined) {
135
- return OPS[chunkStr];
134
+ if (opcodes[chunkStr] !== undefined) {
135
+ return opcodes[chunkStr];
136
136
  }
137
137
  typeforce(types.Hex, chunkStr);
138
138
  return Buffer.from(chunkStr, 'hex');
@@ -144,7 +144,7 @@ export function toStack(chunks) {
144
144
  return chunks.map((op) => {
145
145
  if (singleChunkIsBuffer(op))
146
146
  return op;
147
- if (op === OPS.OP_0)
147
+ if (op === opcodes.OP_0)
148
148
  return Buffer.allocUnsafe(0);
149
149
  return scriptNumber.encode(op - OP_INT_BASE);
150
150
  });
@@ -1,7 +1,7 @@
1
1
  import { BufferReader, BufferWriter, reverseBuffer, varuint } from './bufferutils.js';
2
2
  import * as bcrypto from './crypto.js';
3
3
  import * as bscript from './script.js';
4
- import { OPS as opcodes } from './script.js';
4
+ import { opcodes } from './script.js';
5
5
  import * as types from './types.js';
6
6
  const { typeforce } = types;
7
7
  function varSliceSize(someScript) {