@btc-vision/transaction 1.2.11 → 1.2.13
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/_version.d.ts +1 -1
- package/browser/buffer/BinaryWriter.d.ts +1 -0
- package/browser/index.js +1 -1
- package/build/_version.d.ts +1 -1
- package/build/_version.js +1 -1
- package/build/buffer/BinaryWriter.d.ts +1 -0
- package/build/buffer/BinaryWriter.js +15 -1
- package/build/transaction/browser/extensions/UnisatSigner.js +3 -3
- package/package.json +1 -1
- package/src/_version.ts +1 -1
- package/src/buffer/BinaryWriter.ts +21 -0
- package/src/transaction/browser/extensions/UnisatSigner.ts +3 -3
package/build/_version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.2.
|
|
1
|
+
export declare const version = "1.2.13";
|
package/build/_version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '1.2.
|
|
1
|
+
export const version = '1.2.13';
|
|
@@ -12,6 +12,7 @@ export declare class BinaryWriter {
|
|
|
12
12
|
writeU64(value: u64): void;
|
|
13
13
|
writeSelector(value: Selector): void;
|
|
14
14
|
writeBoolean(value: boolean): void;
|
|
15
|
+
writeI128(bigIntValue: bigint): void;
|
|
15
16
|
writeU256(bigIntValue: bigint): void;
|
|
16
17
|
writeU128(bigIntValue: bigint): void;
|
|
17
18
|
writeBytes(value: Uint8Array | Buffer): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BufferHelper } from '../utils/BufferHelper.js';
|
|
2
|
-
import { ADDRESS_BYTE_LENGTH, U128_BYTE_LENGTH, U16_BYTE_LENGTH, U256_BYTE_LENGTH, U32_BYTE_LENGTH, U64_BYTE_LENGTH, U8_BYTE_LENGTH, } from '../utils/lengths.js';
|
|
2
|
+
import { ADDRESS_BYTE_LENGTH, I128_BYTE_LENGTH, U128_BYTE_LENGTH, U16_BYTE_LENGTH, U256_BYTE_LENGTH, U32_BYTE_LENGTH, U64_BYTE_LENGTH, U8_BYTE_LENGTH, } from '../utils/lengths.js';
|
|
3
3
|
import { BinaryReader } from './BinaryReader.js';
|
|
4
4
|
export class BinaryWriter {
|
|
5
5
|
constructor(length = 0) {
|
|
@@ -39,6 +39,20 @@ export class BinaryWriter {
|
|
|
39
39
|
writeBoolean(value) {
|
|
40
40
|
this.writeU8(value ? 1 : 0);
|
|
41
41
|
}
|
|
42
|
+
writeI128(bigIntValue) {
|
|
43
|
+
if (bigIntValue > 170141183460469231731687303715884105727n ||
|
|
44
|
+
bigIntValue < -170141183460469231731687303715884105728n) {
|
|
45
|
+
throw new Error('i128 value is too large.');
|
|
46
|
+
}
|
|
47
|
+
this.allocSafe(I128_BYTE_LENGTH);
|
|
48
|
+
const bytesToHex = BufferHelper.valueToUint8Array(bigIntValue, I128_BYTE_LENGTH);
|
|
49
|
+
if (bytesToHex.byteLength !== I128_BYTE_LENGTH) {
|
|
50
|
+
throw new Error(`Invalid i128 value: ${bigIntValue}`);
|
|
51
|
+
}
|
|
52
|
+
for (let i = 0; i < bytesToHex.byteLength; i++) {
|
|
53
|
+
this.writeU8(bytesToHex[i]);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
42
56
|
writeU256(bigIntValue) {
|
|
43
57
|
if (bigIntValue >
|
|
44
58
|
115792089237316195423570985008687907853269984665640564039457584007913129639935n) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { crypto as bitCrypto,
|
|
1
|
+
import { crypto as bitCrypto, script as bitScript, networks, Psbt, toXOnly, } from '@btc-vision/bitcoin';
|
|
2
2
|
import { EcKeyPair } from '../../../keypair/EcKeyPair.js';
|
|
3
3
|
import { canSignNonTaprootInput, isTaprootInput } from '../../../signer/SignerUtils.js';
|
|
4
4
|
import { CustomKeypair } from '../BrowserSignerBase.js';
|
|
@@ -42,9 +42,9 @@ export class UnisatSigner extends CustomKeypair {
|
|
|
42
42
|
return this._network;
|
|
43
43
|
}
|
|
44
44
|
get unisat() {
|
|
45
|
-
const module = window.
|
|
45
|
+
const module = window.unisat;
|
|
46
46
|
if (!module) {
|
|
47
|
-
throw new Error('
|
|
47
|
+
throw new Error('Unisat extension not found');
|
|
48
48
|
}
|
|
49
49
|
return module;
|
|
50
50
|
}
|
package/package.json
CHANGED
package/src/_version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '1.2.
|
|
1
|
+
export const version = '1.2.13';
|
|
@@ -3,6 +3,7 @@ import { Address } from '../keypair/Address.js';
|
|
|
3
3
|
import { BufferHelper } from '../utils/BufferHelper.js';
|
|
4
4
|
import {
|
|
5
5
|
ADDRESS_BYTE_LENGTH,
|
|
6
|
+
I128_BYTE_LENGTH,
|
|
6
7
|
U128_BYTE_LENGTH,
|
|
7
8
|
U16_BYTE_LENGTH,
|
|
8
9
|
U256_BYTE_LENGTH,
|
|
@@ -60,6 +61,26 @@ export class BinaryWriter {
|
|
|
60
61
|
this.writeU8(value ? 1 : 0);
|
|
61
62
|
}
|
|
62
63
|
|
|
64
|
+
public writeI128(bigIntValue: bigint): void {
|
|
65
|
+
if (
|
|
66
|
+
bigIntValue > 170141183460469231731687303715884105727n ||
|
|
67
|
+
bigIntValue < -170141183460469231731687303715884105728n
|
|
68
|
+
) {
|
|
69
|
+
throw new Error('i128 value is too large.');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
this.allocSafe(I128_BYTE_LENGTH);
|
|
73
|
+
|
|
74
|
+
const bytesToHex = BufferHelper.valueToUint8Array(bigIntValue, I128_BYTE_LENGTH);
|
|
75
|
+
if (bytesToHex.byteLength !== I128_BYTE_LENGTH) {
|
|
76
|
+
throw new Error(`Invalid i128 value: ${bigIntValue}`);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
for (let i = 0; i < bytesToHex.byteLength; i++) {
|
|
80
|
+
this.writeU8(bytesToHex[i]);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
63
84
|
public writeU256(bigIntValue: bigint): void {
|
|
64
85
|
if (
|
|
65
86
|
bigIntValue >
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
crypto as bitCrypto,
|
|
3
|
+
script as bitScript,
|
|
3
4
|
Network,
|
|
4
5
|
networks,
|
|
5
6
|
Psbt,
|
|
6
|
-
script as bitScript,
|
|
7
7
|
TapScriptSig,
|
|
8
8
|
toXOnly,
|
|
9
9
|
} from '@btc-vision/bitcoin';
|
|
@@ -83,9 +83,9 @@ export class UnisatSigner extends CustomKeypair {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
public get unisat(): Unisat {
|
|
86
|
-
const module = window.
|
|
86
|
+
const module = window.unisat;
|
|
87
87
|
if (!module) {
|
|
88
|
-
throw new Error('
|
|
88
|
+
throw new Error('Unisat extension not found');
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
return module;
|