@btc-vision/transaction 1.7.31 → 1.8.0-alpha.2
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/AUDIT/README.md +9 -0
- package/CHANGELOG.md +5 -0
- package/README.md +62 -18
- package/SECURITY.md +71 -0
- package/browser/_version.d.ts +1 -1
- package/browser/abi/ABICoder.d.ts +8 -0
- package/browser/buffer/BinaryReader.d.ts +16 -1
- package/browser/buffer/BinaryWriter.d.ts +11 -1
- package/browser/deterministic/ExtendedAddressMap.d.ts +19 -0
- package/browser/index.js +1201 -874
- package/browser/keypair/Address.d.ts +4 -1
- package/browser/mnemonic/Mnemonic.d.ts +1 -1
- package/browser/noble-curves.js +1087 -1116
- package/browser/noble-hashes.js +25 -25
- package/browser/opnet.d.ts +1 -0
- package/browser/transaction/browser/WalletNetworks.d.ts +3 -3
- package/browser/transaction/browser/types/Unisat.d.ts +2 -2
- package/browser/utils/lengths.d.ts +3 -1
- package/browser/utils/types.d.ts +3 -0
- package/browser/vendors.js +950 -911
- package/build/_version.d.ts +1 -1
- package/build/_version.js +1 -1
- package/build/abi/ABICoder.d.ts +8 -0
- package/build/abi/ABICoder.js +32 -0
- package/build/buffer/BinaryReader.d.ts +16 -1
- package/build/buffer/BinaryReader.js +66 -1
- package/build/buffer/BinaryWriter.d.ts +11 -1
- package/build/buffer/BinaryWriter.js +66 -1
- package/build/deterministic/ExtendedAddressMap.d.ts +19 -0
- package/build/deterministic/ExtendedAddressMap.js +87 -0
- package/build/keypair/Address.d.ts +4 -1
- package/build/keypair/Address.js +48 -13
- package/build/mnemonic/Mnemonic.d.ts +1 -1
- package/build/mnemonic/Mnemonic.js +2 -2
- package/build/opnet.d.ts +1 -0
- package/build/opnet.js +1 -0
- package/build/transaction/browser/WalletNetworks.d.ts +3 -3
- package/build/transaction/browser/WalletNetworks.js +3 -3
- package/build/transaction/browser/extensions/UnisatSigner.js +3 -3
- package/build/transaction/browser/types/Unisat.d.ts +2 -2
- package/build/transaction/builders/MultiSignTransaction.js +2 -2
- package/build/transaction/shared/TweakedTransaction.js +3 -3
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/build/utils/lengths.d.ts +3 -1
- package/build/utils/lengths.js +3 -1
- package/build/utils/types.d.ts +3 -0
- package/package.json +13 -13
- package/src/_version.ts +1 -1
- package/src/abi/ABICoder.ts +43 -0
- package/src/buffer/BinaryReader.ts +158 -2
- package/src/buffer/BinaryWriter.ts +143 -1
- package/src/deterministic/ExtendedAddressMap.ts +122 -0
- package/src/keypair/Address.ts +79 -14
- package/src/mnemonic/Mnemonic.ts +2 -2
- package/src/opnet.ts +1 -0
- package/src/transaction/browser/WalletNetworks.ts +3 -3
- package/src/transaction/browser/extensions/UnisatSigner.ts +3 -3
- package/src/transaction/browser/types/Unisat.ts +2 -2
- package/src/transaction/builders/MultiSignTransaction.ts +2 -2
- package/src/transaction/shared/TweakedTransaction.ts +3 -3
- package/src/utils/lengths.ts +3 -1
- package/src/utils/types.ts +4 -1
- package/test/binary-reader-writer.test.ts +457 -0
- package/test/derivePath.test.ts +26 -25
package/build/_version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.
|
|
1
|
+
export declare const version = "1.8.0-alpha.2";
|
package/build/_version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '1.
|
|
1
|
+
export const version = '1.8.0-alpha.2';
|
package/build/abi/ABICoder.d.ts
CHANGED
|
@@ -5,15 +5,23 @@ export declare enum ABIDataTypes {
|
|
|
5
5
|
UINT64 = "UINT64",
|
|
6
6
|
UINT128 = "UINT128",
|
|
7
7
|
UINT256 = "UINT256",
|
|
8
|
+
INT8 = "INT8",
|
|
9
|
+
INT16 = "INT16",
|
|
10
|
+
INT32 = "INT32",
|
|
11
|
+
INT64 = "INT64",
|
|
8
12
|
INT128 = "INT128",
|
|
9
13
|
BOOL = "BOOL",
|
|
10
14
|
ADDRESS = "ADDRESS",
|
|
15
|
+
EXTENDED_ADDRESS = "EXTENDED_ADDRESS",
|
|
11
16
|
STRING = "STRING",
|
|
12
17
|
BYTES4 = "BYTES4",
|
|
13
18
|
BYTES32 = "BYTES32",
|
|
14
19
|
BYTES = "BYTES",
|
|
15
20
|
ADDRESS_UINT256_TUPLE = "ADDRESS_UINT256_TUPLE",
|
|
21
|
+
EXTENDED_ADDRESS_UINT256_TUPLE = "EXTENDED_ADDRESS_UINT256_TUPLE",
|
|
22
|
+
SCHNORR_SIGNATURE = "SCHNORR_SIGNATURE",
|
|
16
23
|
ARRAY_OF_ADDRESSES = "ARRAY_OF_ADDRESSES",
|
|
24
|
+
ARRAY_OF_EXTENDED_ADDRESSES = "ARRAY_OF_EXTENDED_ADDRESSES",
|
|
17
25
|
ARRAY_OF_UINT256 = "ARRAY_OF_UINT256",
|
|
18
26
|
ARRAY_OF_UINT128 = "ARRAY_OF_UINT128",
|
|
19
27
|
ARRAY_OF_UINT64 = "ARRAY_OF_UINT64",
|
package/build/abi/ABICoder.js
CHANGED
|
@@ -9,15 +9,23 @@ export var ABIDataTypes;
|
|
|
9
9
|
ABIDataTypes["UINT64"] = "UINT64";
|
|
10
10
|
ABIDataTypes["UINT128"] = "UINT128";
|
|
11
11
|
ABIDataTypes["UINT256"] = "UINT256";
|
|
12
|
+
ABIDataTypes["INT8"] = "INT8";
|
|
13
|
+
ABIDataTypes["INT16"] = "INT16";
|
|
14
|
+
ABIDataTypes["INT32"] = "INT32";
|
|
15
|
+
ABIDataTypes["INT64"] = "INT64";
|
|
12
16
|
ABIDataTypes["INT128"] = "INT128";
|
|
13
17
|
ABIDataTypes["BOOL"] = "BOOL";
|
|
14
18
|
ABIDataTypes["ADDRESS"] = "ADDRESS";
|
|
19
|
+
ABIDataTypes["EXTENDED_ADDRESS"] = "EXTENDED_ADDRESS";
|
|
15
20
|
ABIDataTypes["STRING"] = "STRING";
|
|
16
21
|
ABIDataTypes["BYTES4"] = "BYTES4";
|
|
17
22
|
ABIDataTypes["BYTES32"] = "BYTES32";
|
|
18
23
|
ABIDataTypes["BYTES"] = "BYTES";
|
|
19
24
|
ABIDataTypes["ADDRESS_UINT256_TUPLE"] = "ADDRESS_UINT256_TUPLE";
|
|
25
|
+
ABIDataTypes["EXTENDED_ADDRESS_UINT256_TUPLE"] = "EXTENDED_ADDRESS_UINT256_TUPLE";
|
|
26
|
+
ABIDataTypes["SCHNORR_SIGNATURE"] = "SCHNORR_SIGNATURE";
|
|
20
27
|
ABIDataTypes["ARRAY_OF_ADDRESSES"] = "ARRAY_OF_ADDRESSES";
|
|
28
|
+
ABIDataTypes["ARRAY_OF_EXTENDED_ADDRESSES"] = "ARRAY_OF_EXTENDED_ADDRESSES";
|
|
21
29
|
ABIDataTypes["ARRAY_OF_UINT256"] = "ARRAY_OF_UINT256";
|
|
22
30
|
ABIDataTypes["ARRAY_OF_UINT128"] = "ARRAY_OF_UINT128";
|
|
23
31
|
ABIDataTypes["ARRAY_OF_UINT64"] = "ARRAY_OF_UINT64";
|
|
@@ -65,12 +73,33 @@ export class ABICoder {
|
|
|
65
73
|
case ABIDataTypes.UINT256:
|
|
66
74
|
result.push(byteReader.readU256());
|
|
67
75
|
break;
|
|
76
|
+
case ABIDataTypes.INT8:
|
|
77
|
+
result.push(byteReader.readI8());
|
|
78
|
+
break;
|
|
79
|
+
case ABIDataTypes.INT16:
|
|
80
|
+
result.push(byteReader.readI16());
|
|
81
|
+
break;
|
|
82
|
+
case ABIDataTypes.INT32:
|
|
83
|
+
result.push(byteReader.readI32());
|
|
84
|
+
break;
|
|
85
|
+
case ABIDataTypes.INT64:
|
|
86
|
+
result.push(byteReader.readI64());
|
|
87
|
+
break;
|
|
68
88
|
case ABIDataTypes.INT128:
|
|
69
89
|
result.push(byteReader.readI128());
|
|
70
90
|
break;
|
|
91
|
+
case ABIDataTypes.EXTENDED_ADDRESS:
|
|
92
|
+
result.push(byteReader.readExtendedAddress());
|
|
93
|
+
break;
|
|
71
94
|
case ABIDataTypes.ADDRESS_UINT256_TUPLE:
|
|
72
95
|
result.push(byteReader.readAddressValueTuple());
|
|
73
96
|
break;
|
|
97
|
+
case ABIDataTypes.EXTENDED_ADDRESS_UINT256_TUPLE:
|
|
98
|
+
result.push(byteReader.readExtendedAddressMapU256());
|
|
99
|
+
break;
|
|
100
|
+
case ABIDataTypes.SCHNORR_SIGNATURE:
|
|
101
|
+
result.push(byteReader.readSchnorrSignature());
|
|
102
|
+
break;
|
|
74
103
|
case ABIDataTypes.BYTES:
|
|
75
104
|
result.push(byteReader.readBytesWithLength());
|
|
76
105
|
break;
|
|
@@ -80,6 +109,9 @@ export class ABICoder {
|
|
|
80
109
|
case ABIDataTypes.ARRAY_OF_ADDRESSES:
|
|
81
110
|
result.push(byteReader.readAddressArray());
|
|
82
111
|
break;
|
|
112
|
+
case ABIDataTypes.ARRAY_OF_EXTENDED_ADDRESSES:
|
|
113
|
+
result.push(byteReader.readExtendedAddressArray());
|
|
114
|
+
break;
|
|
83
115
|
case ABIDataTypes.ARRAY_OF_UINT256:
|
|
84
116
|
result.push(byteReader.readU256Array());
|
|
85
117
|
break;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { AddressMap } from '../deterministic/AddressMap.js';
|
|
2
|
+
import { ExtendedAddressMap } from '../deterministic/ExtendedAddressMap.js';
|
|
2
3
|
import { Address } from '../keypair/Address.js';
|
|
3
|
-
import { BufferLike, Selector, u16, u32, u8 } from '../utils/types.js';
|
|
4
|
+
import { BufferLike, i16, i32, i64, i8, Selector, u16, u32, u8 } from '../utils/types.js';
|
|
5
|
+
export interface SchnorrSignature {
|
|
6
|
+
readonly address: Address;
|
|
7
|
+
readonly signature: Uint8Array;
|
|
8
|
+
}
|
|
4
9
|
export declare class BinaryReader {
|
|
5
10
|
private buffer;
|
|
6
11
|
private currentOffset;
|
|
@@ -9,8 +14,13 @@ export declare class BinaryReader {
|
|
|
9
14
|
static bigintCompare(a: bigint, b: bigint): number;
|
|
10
15
|
static numberCompare(a: number, b: number): number;
|
|
11
16
|
setBuffer(bytes: BufferLike): void;
|
|
17
|
+
get byteLength(): number;
|
|
12
18
|
length(): number;
|
|
13
19
|
bytesLeft(): number;
|
|
20
|
+
readI8(): i8;
|
|
21
|
+
readI16(be?: boolean): i16;
|
|
22
|
+
readI32(be?: boolean): i32;
|
|
23
|
+
readI64(be?: boolean): i64;
|
|
14
24
|
readU8(): u8;
|
|
15
25
|
readU16(be?: boolean): u16;
|
|
16
26
|
readU32(be?: boolean): u32;
|
|
@@ -24,6 +34,9 @@ export declare class BinaryReader {
|
|
|
24
34
|
readString(length: u32): string;
|
|
25
35
|
readStringWithLength(be?: boolean): string;
|
|
26
36
|
readAddress(): Address;
|
|
37
|
+
readTweakedPublicKey(): Uint8Array;
|
|
38
|
+
readExtendedAddress(): Address;
|
|
39
|
+
readSchnorrSignature(): SchnorrSignature;
|
|
27
40
|
readBytesWithLength(maxLength?: number, be?: boolean): Uint8Array;
|
|
28
41
|
readArrayOfBuffer(be?: boolean): Uint8Array[];
|
|
29
42
|
readAddressArray(be?: boolean): Address[];
|
|
@@ -36,6 +49,8 @@ export declare class BinaryReader {
|
|
|
36
49
|
readStringArray(be?: boolean): string[];
|
|
37
50
|
readBytesArray(be?: boolean): Uint8Array[];
|
|
38
51
|
readAddressValueTuple(be?: boolean): AddressMap<bigint>;
|
|
52
|
+
readExtendedAddressArray(be?: boolean): Address[];
|
|
53
|
+
readExtendedAddressMapU256(be?: boolean): ExtendedAddressMap<bigint>;
|
|
39
54
|
getOffset(): u16;
|
|
40
55
|
setOffset(offset: u16): void;
|
|
41
56
|
verifyEnd(size: number): void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AddressMap } from '../deterministic/AddressMap.js';
|
|
2
|
+
import { ExtendedAddressMap } from '../deterministic/ExtendedAddressMap.js';
|
|
2
3
|
import { Address } from '../keypair/Address.js';
|
|
3
|
-
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';
|
|
4
|
+
import { ADDRESS_BYTE_LENGTH, EXTENDED_ADDRESS_BYTE_LENGTH, I128_BYTE_LENGTH, I16_BYTE_LENGTH, I32_BYTE_LENGTH, I64_BYTE_LENGTH, I8_BYTE_LENGTH, SCHNORR_SIGNATURE_BYTE_LENGTH, U128_BYTE_LENGTH, U16_BYTE_LENGTH, U256_BYTE_LENGTH, U32_BYTE_LENGTH, U64_BYTE_LENGTH, U8_BYTE_LENGTH, } from '../utils/lengths.js';
|
|
4
5
|
export class BinaryReader {
|
|
5
6
|
constructor(bytes) {
|
|
6
7
|
this.currentOffset = 0;
|
|
@@ -27,12 +28,39 @@ export class BinaryReader {
|
|
|
27
28
|
this.buffer = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
28
29
|
this.currentOffset = 0;
|
|
29
30
|
}
|
|
31
|
+
get byteLength() {
|
|
32
|
+
return this.buffer.byteLength;
|
|
33
|
+
}
|
|
30
34
|
length() {
|
|
31
35
|
return this.buffer.byteLength;
|
|
32
36
|
}
|
|
33
37
|
bytesLeft() {
|
|
34
38
|
return this.buffer.byteLength - this.currentOffset;
|
|
35
39
|
}
|
|
40
|
+
readI8() {
|
|
41
|
+
this.verifyEnd(this.currentOffset + I8_BYTE_LENGTH);
|
|
42
|
+
const value = this.buffer.getInt8(this.currentOffset);
|
|
43
|
+
this.currentOffset += I8_BYTE_LENGTH;
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
readI16(be = true) {
|
|
47
|
+
this.verifyEnd(this.currentOffset + I16_BYTE_LENGTH);
|
|
48
|
+
const value = this.buffer.getInt16(this.currentOffset, !be);
|
|
49
|
+
this.currentOffset += I16_BYTE_LENGTH;
|
|
50
|
+
return value;
|
|
51
|
+
}
|
|
52
|
+
readI32(be = true) {
|
|
53
|
+
this.verifyEnd(this.currentOffset + I32_BYTE_LENGTH);
|
|
54
|
+
const value = this.buffer.getInt32(this.currentOffset, !be);
|
|
55
|
+
this.currentOffset += I32_BYTE_LENGTH;
|
|
56
|
+
return value;
|
|
57
|
+
}
|
|
58
|
+
readI64(be = true) {
|
|
59
|
+
this.verifyEnd(this.currentOffset + I64_BYTE_LENGTH);
|
|
60
|
+
const value = this.buffer.getBigInt64(this.currentOffset, !be);
|
|
61
|
+
this.currentOffset += I64_BYTE_LENGTH;
|
|
62
|
+
return value;
|
|
63
|
+
}
|
|
36
64
|
readU8() {
|
|
37
65
|
this.verifyEnd(this.currentOffset + U8_BYTE_LENGTH);
|
|
38
66
|
const value = this.buffer.getUint8(this.currentOffset);
|
|
@@ -119,6 +147,22 @@ export class BinaryReader {
|
|
|
119
147
|
const bytes = Array.from(this.readBytes(ADDRESS_BYTE_LENGTH));
|
|
120
148
|
return new Address(bytes);
|
|
121
149
|
}
|
|
150
|
+
readTweakedPublicKey() {
|
|
151
|
+
this.verifyEnd(this.currentOffset + ADDRESS_BYTE_LENGTH);
|
|
152
|
+
return this.readBytes(ADDRESS_BYTE_LENGTH);
|
|
153
|
+
}
|
|
154
|
+
readExtendedAddress() {
|
|
155
|
+
this.verifyEnd(this.currentOffset + EXTENDED_ADDRESS_BYTE_LENGTH);
|
|
156
|
+
const tweakedPublicKey = Array.from(this.readBytes(ADDRESS_BYTE_LENGTH));
|
|
157
|
+
const mldsaKeyHash = Array.from(this.readBytes(ADDRESS_BYTE_LENGTH));
|
|
158
|
+
return new Address(mldsaKeyHash, tweakedPublicKey);
|
|
159
|
+
}
|
|
160
|
+
readSchnorrSignature() {
|
|
161
|
+
this.verifyEnd(this.currentOffset + EXTENDED_ADDRESS_BYTE_LENGTH + SCHNORR_SIGNATURE_BYTE_LENGTH);
|
|
162
|
+
const address = this.readExtendedAddress();
|
|
163
|
+
const signature = this.readBytes(SCHNORR_SIGNATURE_BYTE_LENGTH);
|
|
164
|
+
return { address, signature };
|
|
165
|
+
}
|
|
122
166
|
readBytesWithLength(maxLength = 0, be = true) {
|
|
123
167
|
const length = this.readU32(be);
|
|
124
168
|
if (maxLength > 0 && length > maxLength) {
|
|
@@ -219,6 +263,27 @@ export class BinaryReader {
|
|
|
219
263
|
}
|
|
220
264
|
return result;
|
|
221
265
|
}
|
|
266
|
+
readExtendedAddressArray(be = true) {
|
|
267
|
+
const length = this.readU16(be);
|
|
268
|
+
const result = new Array(length);
|
|
269
|
+
for (let i = 0; i < length; i++) {
|
|
270
|
+
result[i] = this.readExtendedAddress();
|
|
271
|
+
}
|
|
272
|
+
return result;
|
|
273
|
+
}
|
|
274
|
+
readExtendedAddressMapU256(be = true) {
|
|
275
|
+
const length = this.readU16(be);
|
|
276
|
+
const result = new ExtendedAddressMap();
|
|
277
|
+
for (let i = 0; i < length; i++) {
|
|
278
|
+
const address = this.readExtendedAddress();
|
|
279
|
+
const value = this.readU256(be);
|
|
280
|
+
if (result.has(address)) {
|
|
281
|
+
throw new Error('Duplicate tweaked address found in map');
|
|
282
|
+
}
|
|
283
|
+
result.set(address, value);
|
|
284
|
+
}
|
|
285
|
+
return result;
|
|
286
|
+
}
|
|
222
287
|
getOffset() {
|
|
223
288
|
return this.currentOffset;
|
|
224
289
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AddressMap } from '../deterministic/AddressMap.js';
|
|
2
|
+
import { ExtendedAddressMap } from '../deterministic/ExtendedAddressMap.js';
|
|
2
3
|
import { Address } from '../keypair/Address.js';
|
|
3
|
-
import { Selector, u16, u32, u64, u8 } from '../utils/types.js';
|
|
4
|
+
import { i16, i32, i64, i8, Selector, u16, u32, u64, u8 } from '../utils/types.js';
|
|
4
5
|
import { BinaryReader } from './BinaryReader.js';
|
|
5
6
|
export declare class BinaryWriter {
|
|
6
7
|
private currentOffset;
|
|
@@ -11,6 +12,10 @@ export declare class BinaryWriter {
|
|
|
11
12
|
writeU16(value: u16, be?: boolean): void;
|
|
12
13
|
writeU32(value: u32, be?: boolean): void;
|
|
13
14
|
writeU64(value: u64, be?: boolean): void;
|
|
15
|
+
writeI8(value: i8): void;
|
|
16
|
+
writeI16(value: i16, be?: boolean): void;
|
|
17
|
+
writeI32(value: i32, be?: boolean): void;
|
|
18
|
+
writeI64(value: i64, be?: boolean): void;
|
|
14
19
|
writeSelector(value: Selector): void;
|
|
15
20
|
writeBoolean(value: boolean): void;
|
|
16
21
|
writeI128(bigIntValue: bigint, be?: boolean): void;
|
|
@@ -20,6 +25,9 @@ export declare class BinaryWriter {
|
|
|
20
25
|
writeString(value: string): void;
|
|
21
26
|
writeStringWithLength(value: string): void;
|
|
22
27
|
writeAddress(value: Address): void;
|
|
28
|
+
writeTweakedPublicKey(value: Address): void;
|
|
29
|
+
writeExtendedAddress(value: Address): void;
|
|
30
|
+
writeSchnorrSignature(address: Address, signature: Uint8Array): void;
|
|
23
31
|
getBuffer(clear?: boolean): Uint8Array;
|
|
24
32
|
reset(): void;
|
|
25
33
|
toBytesReader(): BinaryReader;
|
|
@@ -28,9 +36,11 @@ export declare class BinaryWriter {
|
|
|
28
36
|
clear(): void;
|
|
29
37
|
allocSafe(size: u32): void;
|
|
30
38
|
writeAddressValueTuple(map: AddressMap<bigint>, be?: boolean): void;
|
|
39
|
+
writeExtendedAddressMapU256(map: ExtendedAddressMap<bigint>, be?: boolean): void;
|
|
31
40
|
writeBytesWithLength(value: Uint8Array): void;
|
|
32
41
|
writeArrayOfBuffer(values: Uint8Array[], be?: boolean): void;
|
|
33
42
|
writeAddressArray(value: Address[]): void;
|
|
43
|
+
writeExtendedAddressArray(value: Address[]): void;
|
|
34
44
|
writeU32Array(value: u32[], be?: boolean): void;
|
|
35
45
|
writeU256Array(value: bigint[], be?: boolean): void;
|
|
36
46
|
writeU128Array(value: bigint[], be?: boolean): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BufferHelper } from '../utils/BufferHelper.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';
|
|
2
|
+
import { ADDRESS_BYTE_LENGTH, EXTENDED_ADDRESS_BYTE_LENGTH, I128_BYTE_LENGTH, I16_BYTE_LENGTH, I32_BYTE_LENGTH, I64_BYTE_LENGTH, I8_BYTE_LENGTH, SCHNORR_SIGNATURE_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) {
|
|
@@ -42,6 +42,35 @@ export class BinaryWriter {
|
|
|
42
42
|
this.buffer.setBigUint64(this.currentOffset, value, !be);
|
|
43
43
|
this.currentOffset += 8;
|
|
44
44
|
}
|
|
45
|
+
writeI8(value) {
|
|
46
|
+
if (value < -128 || value > 127)
|
|
47
|
+
throw new Error('i8 value is out of range.');
|
|
48
|
+
this.allocSafe(I8_BYTE_LENGTH);
|
|
49
|
+
this.buffer.setInt8(this.currentOffset, value);
|
|
50
|
+
this.currentOffset += I8_BYTE_LENGTH;
|
|
51
|
+
}
|
|
52
|
+
writeI16(value, be = true) {
|
|
53
|
+
if (value < -32768 || value > 32767)
|
|
54
|
+
throw new Error('i16 value is out of range.');
|
|
55
|
+
this.allocSafe(I16_BYTE_LENGTH);
|
|
56
|
+
this.buffer.setInt16(this.currentOffset, value, !be);
|
|
57
|
+
this.currentOffset += I16_BYTE_LENGTH;
|
|
58
|
+
}
|
|
59
|
+
writeI32(value, be = true) {
|
|
60
|
+
if (value < -2147483648 || value > 2147483647)
|
|
61
|
+
throw new Error('i32 value is out of range.');
|
|
62
|
+
this.allocSafe(I32_BYTE_LENGTH);
|
|
63
|
+
this.buffer.setInt32(this.currentOffset, value, !be);
|
|
64
|
+
this.currentOffset += I32_BYTE_LENGTH;
|
|
65
|
+
}
|
|
66
|
+
writeI64(value, be = true) {
|
|
67
|
+
if (value < -9223372036854775808n || value > 9223372036854775807n) {
|
|
68
|
+
throw new Error('i64 value is out of range.');
|
|
69
|
+
}
|
|
70
|
+
this.allocSafe(I64_BYTE_LENGTH);
|
|
71
|
+
this.buffer.setBigInt64(this.currentOffset, value, !be);
|
|
72
|
+
this.currentOffset += I64_BYTE_LENGTH;
|
|
73
|
+
}
|
|
45
74
|
writeSelector(value) {
|
|
46
75
|
this.writeU32(value, true);
|
|
47
76
|
}
|
|
@@ -134,6 +163,24 @@ export class BinaryWriter {
|
|
|
134
163
|
this.verifyAddress(value);
|
|
135
164
|
this.writeBytes(value);
|
|
136
165
|
}
|
|
166
|
+
writeTweakedPublicKey(value) {
|
|
167
|
+
const tweakedKey = value.tweakedPublicKeyToBuffer();
|
|
168
|
+
this.allocSafe(ADDRESS_BYTE_LENGTH);
|
|
169
|
+
this.writeBytes(tweakedKey);
|
|
170
|
+
}
|
|
171
|
+
writeExtendedAddress(value) {
|
|
172
|
+
this.allocSafe(EXTENDED_ADDRESS_BYTE_LENGTH);
|
|
173
|
+
this.writeTweakedPublicKey(value);
|
|
174
|
+
this.writeBytes(value);
|
|
175
|
+
}
|
|
176
|
+
writeSchnorrSignature(address, signature) {
|
|
177
|
+
if (signature.length !== SCHNORR_SIGNATURE_BYTE_LENGTH) {
|
|
178
|
+
throw new Error(`Invalid Schnorr signature length: expected ${SCHNORR_SIGNATURE_BYTE_LENGTH}, got ${signature.length}`);
|
|
179
|
+
}
|
|
180
|
+
this.allocSafe(EXTENDED_ADDRESS_BYTE_LENGTH + SCHNORR_SIGNATURE_BYTE_LENGTH);
|
|
181
|
+
this.writeExtendedAddress(address);
|
|
182
|
+
this.writeBytes(signature);
|
|
183
|
+
}
|
|
137
184
|
getBuffer(clear = true) {
|
|
138
185
|
const buf = new Uint8Array(this.buffer.byteLength);
|
|
139
186
|
for (let i = 0; i < this.buffer.byteLength; i++) {
|
|
@@ -179,6 +226,15 @@ export class BinaryWriter {
|
|
|
179
226
|
this.writeU256(value, be);
|
|
180
227
|
}
|
|
181
228
|
}
|
|
229
|
+
writeExtendedAddressMapU256(map, be = true) {
|
|
230
|
+
if (map.size > 65535)
|
|
231
|
+
throw new Error('Map size is too large');
|
|
232
|
+
this.writeU16(map.size, be);
|
|
233
|
+
for (const [key, value] of map.entries()) {
|
|
234
|
+
this.writeExtendedAddress(key);
|
|
235
|
+
this.writeU256(value, be);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
182
238
|
writeBytesWithLength(value) {
|
|
183
239
|
this.writeU32(value.length);
|
|
184
240
|
this.writeBytes(value);
|
|
@@ -200,6 +256,15 @@ export class BinaryWriter {
|
|
|
200
256
|
this.writeAddress(value[i]);
|
|
201
257
|
}
|
|
202
258
|
}
|
|
259
|
+
writeExtendedAddressArray(value) {
|
|
260
|
+
if (value.length > 65535)
|
|
261
|
+
throw new Error('Array size is too large');
|
|
262
|
+
this.allocSafe(U16_BYTE_LENGTH + value.length * EXTENDED_ADDRESS_BYTE_LENGTH);
|
|
263
|
+
this.writeU16(value.length);
|
|
264
|
+
for (let i = 0; i < value.length; i++) {
|
|
265
|
+
this.writeExtendedAddress(value[i]);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
203
268
|
writeU32Array(value, be = true) {
|
|
204
269
|
if (value.length > 65535)
|
|
205
270
|
throw new Error('Array size is too large');
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Address } from '../keypair/Address.js';
|
|
2
|
+
export declare class ExtendedAddressMap<V> {
|
|
3
|
+
private indexMap;
|
|
4
|
+
private _keys;
|
|
5
|
+
private _values;
|
|
6
|
+
constructor(iterable?: ReadonlyArray<readonly [Address, V]> | null);
|
|
7
|
+
get size(): number;
|
|
8
|
+
set(key: Address, value: V): this;
|
|
9
|
+
get(key: Address): V | undefined;
|
|
10
|
+
has(key: Address): boolean;
|
|
11
|
+
delete(key: Address): boolean;
|
|
12
|
+
clear(): void;
|
|
13
|
+
indexOf(address: Address): number;
|
|
14
|
+
entries(): IterableIterator<[Address, V]>;
|
|
15
|
+
keys(): IterableIterator<Address>;
|
|
16
|
+
values(): IterableIterator<V>;
|
|
17
|
+
forEach(callback: (value: V, key: Address, map: ExtendedAddressMap<V>) => void, thisArg?: unknown): void;
|
|
18
|
+
[Symbol.iterator](): IterableIterator<[Address, V]>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { FastMap } from './FastMap.js';
|
|
2
|
+
export class ExtendedAddressMap {
|
|
3
|
+
constructor(iterable) {
|
|
4
|
+
this._keys = [];
|
|
5
|
+
this._values = [];
|
|
6
|
+
this.indexMap = new FastMap();
|
|
7
|
+
if (iterable) {
|
|
8
|
+
for (const [key, value] of iterable) {
|
|
9
|
+
this.set(key, value);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
get size() {
|
|
14
|
+
return this._keys.length;
|
|
15
|
+
}
|
|
16
|
+
set(key, value) {
|
|
17
|
+
const keyBigInt = key.tweakedToBigInt();
|
|
18
|
+
const existingIndex = this.indexMap.get(keyBigInt);
|
|
19
|
+
if (existingIndex !== undefined) {
|
|
20
|
+
this._values[existingIndex] = value;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
const newIndex = this._keys.length;
|
|
24
|
+
this._keys.push(key);
|
|
25
|
+
this._values.push(value);
|
|
26
|
+
this.indexMap.set(keyBigInt, newIndex);
|
|
27
|
+
}
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
get(key) {
|
|
31
|
+
const keyBigInt = key.tweakedToBigInt();
|
|
32
|
+
const index = this.indexMap.get(keyBigInt);
|
|
33
|
+
if (index === undefined) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
return this._values[index];
|
|
37
|
+
}
|
|
38
|
+
has(key) {
|
|
39
|
+
return this.indexMap.has(key.tweakedToBigInt());
|
|
40
|
+
}
|
|
41
|
+
delete(key) {
|
|
42
|
+
const keyBigInt = key.tweakedToBigInt();
|
|
43
|
+
const index = this.indexMap.get(keyBigInt);
|
|
44
|
+
if (index === undefined) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
this._keys.splice(index, 1);
|
|
48
|
+
this._values.splice(index, 1);
|
|
49
|
+
this.indexMap.clear();
|
|
50
|
+
for (let i = 0; i < this._keys.length; i++) {
|
|
51
|
+
this.indexMap.set(this._keys[i].tweakedToBigInt(), i);
|
|
52
|
+
}
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
clear() {
|
|
56
|
+
this.indexMap.clear();
|
|
57
|
+
this._keys = [];
|
|
58
|
+
this._values = [];
|
|
59
|
+
}
|
|
60
|
+
indexOf(address) {
|
|
61
|
+
const index = this.indexMap.get(address.tweakedToBigInt());
|
|
62
|
+
return index !== undefined ? index : -1;
|
|
63
|
+
}
|
|
64
|
+
*entries() {
|
|
65
|
+
for (let i = 0; i < this._keys.length; i++) {
|
|
66
|
+
yield [this._keys[i], this._values[i]];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
*keys() {
|
|
70
|
+
for (const key of this._keys) {
|
|
71
|
+
yield key;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
*values() {
|
|
75
|
+
for (const value of this._values) {
|
|
76
|
+
yield value;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
forEach(callback, thisArg) {
|
|
80
|
+
for (let i = 0; i < this._keys.length; i++) {
|
|
81
|
+
callback.call(thisArg, this._values[i], this._keys[i], this);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
*[Symbol.iterator]() {
|
|
85
|
+
yield* this.entries();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -16,8 +16,9 @@ export declare class Address extends Uint8Array {
|
|
|
16
16
|
static fromString(mldsaPublicKey: string, legacyPublicKey?: string): Address;
|
|
17
17
|
static wrap(bytes: ArrayLike<number>): Address;
|
|
18
18
|
static uncompressedToCompressed(publicKey: ArrayLike<number>): Buffer;
|
|
19
|
-
static fromBigInt(value: bigint): Address;
|
|
19
|
+
static fromBigInt(value: bigint, tweakedValue?: bigint): Address;
|
|
20
20
|
static fromUint64Array(w0: bigint, w1: bigint, w2: bigint, w3: bigint): Address;
|
|
21
|
+
private static bigintToUint8Array;
|
|
21
22
|
toUint64Array(): [bigint, bigint, bigint, bigint];
|
|
22
23
|
isDead(): boolean;
|
|
23
24
|
toHex(): string;
|
|
@@ -30,6 +31,7 @@ export declare class Address extends Uint8Array {
|
|
|
30
31
|
toHybridPublicKeyBuffer(): Buffer;
|
|
31
32
|
originalPublicKeyBuffer(): Buffer;
|
|
32
33
|
toBigInt(): bigint;
|
|
34
|
+
tweakedToBigInt(): bigint;
|
|
33
35
|
equals(a: Address): boolean;
|
|
34
36
|
lessThan(a: Address): boolean;
|
|
35
37
|
greaterThan(a: Address): boolean;
|
|
@@ -48,6 +50,7 @@ export declare class Address extends Uint8Array {
|
|
|
48
50
|
p2op(network: Network): string;
|
|
49
51
|
toTweakedHybridPublicKeyHex(): string;
|
|
50
52
|
toTweakedHybridPublicKeyBuffer(): Buffer;
|
|
53
|
+
private ensureTweakedUncompressed;
|
|
51
54
|
private setMldsaKey;
|
|
52
55
|
private ensureLegacyProcessed;
|
|
53
56
|
private autoFormat;
|
package/build/keypair/Address.js
CHANGED
|
@@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _Address_p2tr, _Address_p2op, _Address_network, _Address_originalPublicKey, _Address_keyPair, _Address_uncompressed, _Address_tweakedUncompressed, _Address_p2wda, _Address_mldsaPublicKey, _Address_cachedBigInt, _Address_cachedUint64Array, _Address_originalMDLSAPublicKey, _Address_mldsaLevel, _Address_pendingLegacyKey, _Address_legacyProcessed, _Address_legacyPublicKey;
|
|
12
|
+
var _Address_p2tr, _Address_p2op, _Address_network, _Address_originalPublicKey, _Address_keyPair, _Address_uncompressed, _Address_tweakedUncompressed, _Address_p2wda, _Address_mldsaPublicKey, _Address_cachedBigInt, _Address_cachedBigIntTweaked, _Address_cachedUint64Array, _Address_originalMDLSAPublicKey, _Address_mldsaLevel, _Address_pendingLegacyKey, _Address_legacyProcessed, _Address_legacyPublicKey;
|
|
13
13
|
import { decompressPublicKey, toXOnly } from '@btc-vision/bitcoin';
|
|
14
14
|
import { ADDRESS_BYTE_LENGTH } from '../utils/lengths.js';
|
|
15
15
|
import { AddressVerificator } from './AddressVerificator.js';
|
|
@@ -32,6 +32,7 @@ export class Address extends Uint8Array {
|
|
|
32
32
|
_Address_p2wda.set(this, void 0);
|
|
33
33
|
_Address_mldsaPublicKey.set(this, void 0);
|
|
34
34
|
_Address_cachedBigInt.set(this, void 0);
|
|
35
|
+
_Address_cachedBigIntTweaked.set(this, void 0);
|
|
35
36
|
_Address_cachedUint64Array.set(this, void 0);
|
|
36
37
|
_Address_originalMDLSAPublicKey.set(this, void 0);
|
|
37
38
|
_Address_mldsaLevel.set(this, void 0);
|
|
@@ -118,14 +119,10 @@ export class Address extends Uint8Array {
|
|
|
118
119
|
compressed.set(x, 1);
|
|
119
120
|
return compressed;
|
|
120
121
|
}
|
|
121
|
-
static fromBigInt(value) {
|
|
122
|
-
const
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
view.setBigUint64(8, (value >> 128n) & 0xffffffffffffffffn, false);
|
|
126
|
-
view.setBigUint64(16, (value >> 64n) & 0xffffffffffffffffn, false);
|
|
127
|
-
view.setBigUint64(24, value & 0xffffffffffffffffn, false);
|
|
128
|
-
return new Address(buffer);
|
|
122
|
+
static fromBigInt(value, tweakedValue) {
|
|
123
|
+
const address = Address.bigintToUint8Array(value);
|
|
124
|
+
const legacyAddress = tweakedValue !== undefined ? Address.bigintToUint8Array(tweakedValue) : undefined;
|
|
125
|
+
return new Address(address, legacyAddress);
|
|
129
126
|
}
|
|
130
127
|
static fromUint64Array(w0, w1, w2, w3) {
|
|
131
128
|
const buffer = new Uint8Array(32);
|
|
@@ -136,6 +133,15 @@ export class Address extends Uint8Array {
|
|
|
136
133
|
view.setBigUint64(24, w3, false);
|
|
137
134
|
return new Address(buffer);
|
|
138
135
|
}
|
|
136
|
+
static bigintToUint8Array(value) {
|
|
137
|
+
const buffer = new Uint8Array(32);
|
|
138
|
+
const view = new DataView(buffer.buffer);
|
|
139
|
+
view.setBigUint64(0, (value >> 192n) & 0xffffffffffffffffn, false);
|
|
140
|
+
view.setBigUint64(8, (value >> 128n) & 0xffffffffffffffffn, false);
|
|
141
|
+
view.setBigUint64(16, (value >> 64n) & 0xffffffffffffffffn, false);
|
|
142
|
+
view.setBigUint64(24, value & 0xffffffffffffffffn, false);
|
|
143
|
+
return buffer;
|
|
144
|
+
}
|
|
139
145
|
toUint64Array() {
|
|
140
146
|
if (__classPrivateFieldGet(this, _Address_cachedUint64Array, "f") !== undefined) {
|
|
141
147
|
return __classPrivateFieldGet(this, _Address_cachedUint64Array, "f");
|
|
@@ -223,6 +229,20 @@ export class Address extends Uint8Array {
|
|
|
223
229
|
view.getBigUint64(24, false), "f");
|
|
224
230
|
return __classPrivateFieldGet(this, _Address_cachedBigInt, "f");
|
|
225
231
|
}
|
|
232
|
+
tweakedToBigInt() {
|
|
233
|
+
if (!this.legacyPublicKey) {
|
|
234
|
+
throw new Error('Legacy public key not set');
|
|
235
|
+
}
|
|
236
|
+
if (__classPrivateFieldGet(this, _Address_cachedBigIntTweaked, "f") !== undefined) {
|
|
237
|
+
return __classPrivateFieldGet(this, _Address_cachedBigIntTweaked, "f");
|
|
238
|
+
}
|
|
239
|
+
const view = new DataView(this.legacyPublicKey.buffer, this.byteOffset, 32);
|
|
240
|
+
__classPrivateFieldSet(this, _Address_cachedBigIntTweaked, (view.getBigUint64(0, false) << 192n) |
|
|
241
|
+
(view.getBigUint64(8, false) << 128n) |
|
|
242
|
+
(view.getBigUint64(16, false) << 64n) |
|
|
243
|
+
view.getBigUint64(24, false), "f");
|
|
244
|
+
return __classPrivateFieldGet(this, _Address_cachedBigIntTweaked, "f");
|
|
245
|
+
}
|
|
226
246
|
equals(a) {
|
|
227
247
|
const b = this;
|
|
228
248
|
if (a.length !== b.length) {
|
|
@@ -369,6 +389,7 @@ export class Address extends Uint8Array {
|
|
|
369
389
|
}
|
|
370
390
|
toTweakedHybridPublicKeyHex() {
|
|
371
391
|
this.ensureLegacyProcessed();
|
|
392
|
+
this.ensureTweakedUncompressed();
|
|
372
393
|
if (!__classPrivateFieldGet(this, _Address_tweakedUncompressed, "f")) {
|
|
373
394
|
throw new Error('Legacy public key not set');
|
|
374
395
|
}
|
|
@@ -376,11 +397,28 @@ export class Address extends Uint8Array {
|
|
|
376
397
|
}
|
|
377
398
|
toTweakedHybridPublicKeyBuffer() {
|
|
378
399
|
this.ensureLegacyProcessed();
|
|
400
|
+
this.ensureTweakedUncompressed();
|
|
379
401
|
if (!__classPrivateFieldGet(this, _Address_tweakedUncompressed, "f")) {
|
|
380
402
|
throw new Error('Legacy public key not set');
|
|
381
403
|
}
|
|
382
404
|
return __classPrivateFieldGet(this, _Address_tweakedUncompressed, "f");
|
|
383
405
|
}
|
|
406
|
+
ensureTweakedUncompressed() {
|
|
407
|
+
if (__classPrivateFieldGet(this, _Address_tweakedUncompressed, "f"))
|
|
408
|
+
return;
|
|
409
|
+
const key = __classPrivateFieldGet(this, _Address_legacyPublicKey, "f");
|
|
410
|
+
if (!key)
|
|
411
|
+
return;
|
|
412
|
+
if (key.length === ADDRESS_BYTE_LENGTH && !__classPrivateFieldGet(this, _Address_originalPublicKey, "f")) {
|
|
413
|
+
try {
|
|
414
|
+
const buf = Buffer.alloc(ADDRESS_BYTE_LENGTH);
|
|
415
|
+
buf.set(key);
|
|
416
|
+
__classPrivateFieldSet(this, _Address_tweakedUncompressed, ContractAddress.generateHybridKeyFromHash(buf), "f");
|
|
417
|
+
}
|
|
418
|
+
catch {
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
384
422
|
setMldsaKey(mldsaPublicKey) {
|
|
385
423
|
if (mldsaPublicKey.length === ADDRESS_BYTE_LENGTH) {
|
|
386
424
|
const buf = new Uint8Array(ADDRESS_BYTE_LENGTH);
|
|
@@ -409,9 +447,6 @@ export class Address extends Uint8Array {
|
|
|
409
447
|
if (!pending)
|
|
410
448
|
return;
|
|
411
449
|
if (pending.length === ADDRESS_BYTE_LENGTH) {
|
|
412
|
-
const buf = Buffer.alloc(ADDRESS_BYTE_LENGTH);
|
|
413
|
-
buf.set(pending);
|
|
414
|
-
__classPrivateFieldSet(this, _Address_tweakedUncompressed, ContractAddress.generateHybridKeyFromHash(buf), "f");
|
|
415
450
|
__classPrivateFieldSet(this, _Address_legacyPublicKey, pending, "f");
|
|
416
451
|
}
|
|
417
452
|
else {
|
|
@@ -434,4 +469,4 @@ export class Address extends Uint8Array {
|
|
|
434
469
|
__classPrivateFieldGet(this, _Address_legacyPublicKey, "f").set(tweakedBytes);
|
|
435
470
|
}
|
|
436
471
|
}
|
|
437
|
-
_Address_p2tr = new WeakMap(), _Address_p2op = new WeakMap(), _Address_network = new WeakMap(), _Address_originalPublicKey = new WeakMap(), _Address_keyPair = new WeakMap(), _Address_uncompressed = new WeakMap(), _Address_tweakedUncompressed = new WeakMap(), _Address_p2wda = new WeakMap(), _Address_mldsaPublicKey = new WeakMap(), _Address_cachedBigInt = new WeakMap(), _Address_cachedUint64Array = new WeakMap(), _Address_originalMDLSAPublicKey = new WeakMap(), _Address_mldsaLevel = new WeakMap(), _Address_pendingLegacyKey = new WeakMap(), _Address_legacyProcessed = new WeakMap(), _Address_legacyPublicKey = new WeakMap();
|
|
472
|
+
_Address_p2tr = new WeakMap(), _Address_p2op = new WeakMap(), _Address_network = new WeakMap(), _Address_originalPublicKey = new WeakMap(), _Address_keyPair = new WeakMap(), _Address_uncompressed = new WeakMap(), _Address_tweakedUncompressed = new WeakMap(), _Address_p2wda = new WeakMap(), _Address_mldsaPublicKey = new WeakMap(), _Address_cachedBigInt = new WeakMap(), _Address_cachedBigIntTweaked = new WeakMap(), _Address_cachedUint64Array = new WeakMap(), _Address_originalMDLSAPublicKey = new WeakMap(), _Address_mldsaLevel = new WeakMap(), _Address_pendingLegacyKey = new WeakMap(), _Address_legacyProcessed = new WeakMap(), _Address_legacyPublicKey = new WeakMap();
|
|
@@ -22,7 +22,7 @@ export declare class Mnemonic {
|
|
|
22
22
|
static generate(strength?: MnemonicStrength, passphrase?: string, network?: Network, securityLevel?: MLDSASecurityLevel): Mnemonic;
|
|
23
23
|
static validate(phrase: string): boolean;
|
|
24
24
|
derive(index?: number, account?: number, isChange?: boolean, bipStandard?: BIPStandard): Wallet;
|
|
25
|
-
|
|
25
|
+
deriveOPWallet(addressType?: AddressTypes, index?: number, account?: number, isChange?: boolean): Wallet;
|
|
26
26
|
deriveMultipleUnisat(addressType?: AddressTypes, count?: number, startIndex?: number, account?: number, isChange?: boolean): Wallet[];
|
|
27
27
|
deriveMultiple(count: number, startIndex?: number, account?: number, isChange?: boolean, bipStandard?: BIPStandard): Wallet[];
|
|
28
28
|
deriveCustomPath(classicalPath: string, quantumPath: string): Wallet;
|