@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.
- package/browser/index.d.ts +1 -1
- package/browser/index.js +1 -1
- package/browser/opcodes.d.ts +125 -0
- package/browser/script.d.ts +2 -2
- package/build/address.js +6 -5
- package/build/bufferutils.js +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.js +1 -1
- package/build/opcodes.d.ts +125 -0
- package/build/opcodes.js +126 -0
- package/build/payments/embed.js +1 -1
- package/build/payments/p2ms.js +1 -1
- package/build/payments/p2op.js +1 -1
- package/build/payments/p2pk.js +1 -1
- package/build/payments/p2pkh.js +1 -1
- package/build/payments/p2sh.js +3 -3
- package/build/payments/p2tr.js +1 -1
- package/build/payments/p2wpkh.js +2 -2
- package/build/payments/p2wsh.js +2 -2
- package/build/psbt.js +2 -2
- package/build/push_data.js +9 -9
- package/build/script.d.ts +2 -2
- package/build/script.js +12 -12
- package/build/transaction.js +1 -1
- package/package.json +1 -1
- package/src/address.ts +304 -303
- package/src/bufferutils.ts +1 -1
- package/src/index.ts +1 -1
- package/src/{ops.ts → opcodes.ts} +4 -6
- package/src/payments/embed.ts +1 -1
- package/src/payments/p2ms.ts +1 -1
- package/src/payments/p2op.ts +1 -1
- package/src/payments/p2pk.ts +1 -1
- package/src/payments/p2pkh.ts +1 -1
- package/src/payments/p2sh.ts +210 -210
- package/src/payments/p2tr.ts +1 -1
- package/src/payments/p2wpkh.ts +144 -144
- package/src/payments/p2wsh.ts +217 -217
- package/src/psbt.ts +2 -2
- package/src/push_data.ts +9 -9
- package/src/script.ts +12 -12
- package/src/transaction.ts +1 -1
- package/test/script.spec.ts +1 -1
package/build/script.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import * as bip66 from './bip66.js';
|
|
2
|
-
import {
|
|
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 =
|
|
9
|
-
export {
|
|
8
|
+
const OP_INT_BASE = opcodes.OP_RESERVED;
|
|
9
|
+
export { opcodes };
|
|
10
10
|
function isOPInt(value) {
|
|
11
11
|
return (types.Number(value) &&
|
|
12
|
-
(value ===
|
|
13
|
-
(value >=
|
|
14
|
-
value ===
|
|
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
|
|
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
|
|
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 >
|
|
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 (
|
|
135
|
-
return
|
|
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 ===
|
|
147
|
+
if (op === opcodes.OP_0)
|
|
148
148
|
return Buffer.allocUnsafe(0);
|
|
149
149
|
return scriptNumber.encode(op - OP_INT_BASE);
|
|
150
150
|
});
|
package/build/transaction.js
CHANGED
|
@@ -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 {
|
|
4
|
+
import { opcodes } from './script.js';
|
|
5
5
|
import * as types from './types.js';
|
|
6
6
|
const { typeforce } = types;
|
|
7
7
|
function varSliceSize(someScript) {
|