@btc-vision/transaction 1.1.13 → 1.1.15
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/BinaryReader.d.ts +2 -2
- package/browser/buffer/BinaryWriter.d.ts +2 -2
- package/browser/index.js +1 -1
- package/browser/index.js.LICENSE.txt +2 -0
- package/browser/opnet.d.ts +26 -24
- package/browser/transaction/browser/extensions/XverseSigner.d.ts +36 -0
- package/browser/transaction/browser/types/Xverse.d.ts +79 -0
- package/browser/utils/lengths.d.ts +16 -0
- package/browser/utils/types.d.ts +0 -1
- package/build/_version.d.ts +1 -1
- package/build/_version.js +1 -1
- package/build/buffer/BinaryReader.d.ts +2 -2
- package/build/buffer/BinaryReader.js +14 -12
- package/build/buffer/BinaryWriter.d.ts +2 -2
- package/build/buffer/BinaryWriter.js +12 -12
- package/build/keypair/Address.js +10 -8
- package/build/opnet.d.ts +26 -24
- package/build/opnet.js +26 -24
- package/build/transaction/TransactionFactory.js +11 -2
- package/build/transaction/browser/extensions/XverseSigner.d.ts +36 -0
- package/build/transaction/browser/extensions/XverseSigner.js +299 -0
- package/build/transaction/browser/types/Xverse.d.ts +79 -0
- package/build/transaction/browser/types/Xverse.js +6 -0
- package/build/utils/BufferHelper.js +2 -1
- package/build/utils/lengths.d.ts +16 -0
- package/build/utils/lengths.js +15 -0
- package/build/utils/types.d.ts +0 -1
- package/build/utils/types.js +1 -1
- package/package.json +1 -1
- package/src/_version.ts +1 -1
- package/src/buffer/BinaryReader.ts +24 -12
- package/src/buffer/BinaryWriter.ts +23 -15
- package/src/keypair/Address.ts +11 -9
- package/src/opnet.ts +26 -24
- package/src/transaction/TransactionFactory.ts +12 -2
- package/src/transaction/browser/extensions/XverseSigner.ts +429 -0
- package/src/transaction/browser/types/Xverse.ts +104 -0
- package/src/utils/BufferHelper.ts +2 -1
- package/src/utils/lengths.ts +20 -0
- package/src/utils/types.ts +0 -2
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
|
|
15
15
|
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
16
16
|
|
|
17
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
18
|
+
|
|
17
19
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
18
20
|
|
|
19
21
|
/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */
|
package/browser/opnet.d.ts
CHANGED
|
@@ -1,57 +1,59 @@
|
|
|
1
1
|
export { version } from './_version.js';
|
|
2
2
|
export * from './bytecode/Compressor.js';
|
|
3
|
-
export * from './generators/Generator.js';
|
|
4
3
|
export * from './generators/builders/CalldataGenerator.js';
|
|
5
|
-
export * from './generators/builders/LegacyCalldataGenerator.js';
|
|
6
|
-
export * from './generators/builders/DeploymentGenerator.js';
|
|
7
4
|
export * from './generators/builders/CustomGenerator.js';
|
|
5
|
+
export * from './generators/builders/DeploymentGenerator.js';
|
|
6
|
+
export * from './generators/builders/LegacyCalldataGenerator.js';
|
|
8
7
|
export * from './generators/builders/MultiSignGenerator.js';
|
|
9
8
|
export * from './generators/Features.js';
|
|
9
|
+
export * from './generators/Generator.js';
|
|
10
10
|
export * from './generators/AddressGenerator.js';
|
|
11
11
|
export * from './verification/TapscriptVerificator.js';
|
|
12
|
+
export * from './keypair/AddressVerificator.js';
|
|
12
13
|
export * from './keypair/EcKeyPair.js';
|
|
13
|
-
export * from './keypair/Wallet.js';
|
|
14
14
|
export * from './keypair/interfaces/IWallet.js';
|
|
15
|
-
export * from './keypair/AddressVerificator.js';
|
|
16
15
|
export * from './keypair/MessageSigner.js';
|
|
16
|
+
export * from './keypair/Wallet.js';
|
|
17
17
|
export * from './metadata/ContractBaseMetadata.js';
|
|
18
18
|
export * from './network/ChainId.js';
|
|
19
19
|
export * from './signer/TweakedSigner.js';
|
|
20
|
-
export * from './transaction/
|
|
20
|
+
export * from './transaction/enums/TransactionType.js';
|
|
21
21
|
export * from './transaction/interfaces/ITransactionParameters.js';
|
|
22
22
|
export * from './transaction/interfaces/Tap.js';
|
|
23
|
-
export * from './transaction/
|
|
24
|
-
export * from './transaction/builders/InteractionTransaction.js';
|
|
25
|
-
export * from './transaction/builders/FundingTransaction.js';
|
|
26
|
-
export * from './transaction/builders/TransactionBuilder.js';
|
|
27
|
-
export * from './transaction/builders/SharedInteractionTransaction.js';
|
|
28
|
-
export * from './transaction/builders/DeploymentTransaction.js';
|
|
23
|
+
export * from './transaction/TransactionFactory.js';
|
|
29
24
|
export * from './transaction/builders/CustomScriptTransaction.js';
|
|
25
|
+
export * from './transaction/builders/DeploymentTransaction.js';
|
|
26
|
+
export * from './transaction/builders/FundingTransaction.js';
|
|
27
|
+
export * from './transaction/builders/InteractionTransaction.js';
|
|
30
28
|
export * from './transaction/builders/MultiSignTransaction.js';
|
|
29
|
+
export * from './transaction/builders/SharedInteractionTransaction.js';
|
|
30
|
+
export * from './transaction/builders/TransactionBuilder.js';
|
|
31
31
|
export * from './utils/BitcoinUtils.js';
|
|
32
32
|
export * from './utxo/interfaces/IUTXO.js';
|
|
33
33
|
export * from './utxo/OPNetLimitedProvider.js';
|
|
34
34
|
export * from './transaction/processor/PsbtTransaction.js';
|
|
35
|
+
export * from './transaction/psbt/PSBTTypes.js';
|
|
35
36
|
export * from './transaction/shared/TweakedTransaction.js';
|
|
36
37
|
export * from './utxo/interfaces/BroadcastResponse.js';
|
|
37
|
-
export * from './transaction/psbt/PSBTTypes.js';
|
|
38
38
|
export * from './transaction/shared/P2TR_MS.js';
|
|
39
|
-
export * from './consensus/ConsensusConfig.js';
|
|
40
39
|
export * from './consensus/Consensus.js';
|
|
40
|
+
export * from './consensus/ConsensusConfig.js';
|
|
41
41
|
export * from './consensus/metadata/RoswellConsensus.js';
|
|
42
|
-
export * from './utils/BufferHelper.js';
|
|
43
|
-
export * from './utils/types.js';
|
|
44
|
-
export * from './keypair/Address.js';
|
|
45
|
-
export * from './event/NetEvent.js';
|
|
46
|
-
export * from './deterministic/DeterministicMap.js';
|
|
47
|
-
export * from './deterministic/DeterministicSet.js';
|
|
48
|
-
export * from './deterministic/AddressMap.js';
|
|
49
|
-
export * from './deterministic/AddressSet.js';
|
|
50
42
|
export * from './abi/ABICoder.js';
|
|
51
|
-
export * from './buffer/BinaryWriter.js';
|
|
52
43
|
export * from './buffer/BinaryReader.js';
|
|
44
|
+
export * from './buffer/BinaryWriter.js';
|
|
45
|
+
export * from './deterministic/AddressMap.js';
|
|
46
|
+
export * from './deterministic/AddressSet.js';
|
|
47
|
+
export * from './deterministic/DeterministicMap.js';
|
|
48
|
+
export * from './deterministic/DeterministicSet.js';
|
|
49
|
+
export * from './event/NetEvent.js';
|
|
50
|
+
export * from './keypair/Address.js';
|
|
51
|
+
export * from './utils/BufferHelper.js';
|
|
52
|
+
export * from './utils/types.js';
|
|
53
53
|
export * from './transaction/browser/BrowserSignerBase.js';
|
|
54
54
|
export * from './transaction/browser/extensions/UnisatSigner.js';
|
|
55
|
+
export * from './transaction/browser/extensions/XverseSigner.js';
|
|
55
56
|
export * from './transaction/browser/types/Unisat.js';
|
|
56
|
-
export * from './transaction/browser/
|
|
57
|
+
export * from './transaction/browser/types/Xverse.js';
|
|
57
58
|
export * from './metadata/tokens.js';
|
|
59
|
+
export * from './transaction/browser/Web3Provider.js';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Network, Psbt } from '@btc-vision/bitcoin';
|
|
2
|
+
import { CustomKeypair } from '../BrowserSignerBase.js';
|
|
3
|
+
import { Xverse } from '../types/Xverse.js';
|
|
4
|
+
declare global {
|
|
5
|
+
interface Window {
|
|
6
|
+
BitcoinProvider?: Xverse;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export declare class XverseSigner extends CustomKeypair {
|
|
10
|
+
private isInitialized;
|
|
11
|
+
constructor();
|
|
12
|
+
private _p2tr;
|
|
13
|
+
get p2tr(): string;
|
|
14
|
+
private _p2wpkh;
|
|
15
|
+
get p2wpkh(): string;
|
|
16
|
+
private _addresses;
|
|
17
|
+
get addresses(): string[];
|
|
18
|
+
private _publicKey;
|
|
19
|
+
get publicKey(): Buffer;
|
|
20
|
+
_network: Network | undefined;
|
|
21
|
+
get network(): Network;
|
|
22
|
+
get BitcoinProvider(): Xverse;
|
|
23
|
+
init(): Promise<void>;
|
|
24
|
+
getPublicKey(): Buffer;
|
|
25
|
+
sign(_hash: Buffer, _lowR?: boolean): Buffer;
|
|
26
|
+
signSchnorr(_hash: Buffer): Buffer;
|
|
27
|
+
verify(_hash: Buffer, _signature: Buffer): boolean;
|
|
28
|
+
signTaprootInput(transaction: Psbt, i: number, sighashTypes: number[]): Promise<void>;
|
|
29
|
+
signInput(transaction: Psbt, i: number, sighashTypes: number[]): Promise<void>;
|
|
30
|
+
multiSignPsbt(transactions: Psbt[]): Promise<void>;
|
|
31
|
+
private hasAlreadySignedTapScriptSig;
|
|
32
|
+
private hasAlreadyPartialSig;
|
|
33
|
+
private combine;
|
|
34
|
+
private signAllTweaked;
|
|
35
|
+
private getNonDuplicateScriptSig;
|
|
36
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export declare enum XverseNetwork {
|
|
2
|
+
mainnet = "mainnet",
|
|
3
|
+
testnet = "testnet",
|
|
4
|
+
signet = "Signet"
|
|
5
|
+
}
|
|
6
|
+
export type XverseRPCResponse<T = unknown> = {
|
|
7
|
+
id: string;
|
|
8
|
+
jsonrpc: string;
|
|
9
|
+
result: T;
|
|
10
|
+
};
|
|
11
|
+
export type XverseRPCError = {
|
|
12
|
+
id: string;
|
|
13
|
+
jsonrpc: string;
|
|
14
|
+
error: {
|
|
15
|
+
code: number;
|
|
16
|
+
message: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export type XverseRPCGetAccountResponse = XverseRPCResponse<{
|
|
20
|
+
addresses: {
|
|
21
|
+
address: string;
|
|
22
|
+
addressType: string;
|
|
23
|
+
publicKey: string;
|
|
24
|
+
purpose: string;
|
|
25
|
+
}[];
|
|
26
|
+
}> | XverseRPCError;
|
|
27
|
+
export type XverseRPCSignPsbtResponse = XverseRPCResponse<{
|
|
28
|
+
psbt: string;
|
|
29
|
+
}> | XverseRPCError;
|
|
30
|
+
interface InscriptionData {
|
|
31
|
+
address: string;
|
|
32
|
+
amount: number;
|
|
33
|
+
asset: string;
|
|
34
|
+
fee: number;
|
|
35
|
+
nonce: number;
|
|
36
|
+
recipient: string;
|
|
37
|
+
}
|
|
38
|
+
interface InscriptionResult {
|
|
39
|
+
txid: string;
|
|
40
|
+
}
|
|
41
|
+
interface RepeatInscriptionsData {
|
|
42
|
+
inscriptions: InscriptionData[];
|
|
43
|
+
}
|
|
44
|
+
interface TransactionResult {
|
|
45
|
+
txid: string;
|
|
46
|
+
}
|
|
47
|
+
interface SignedMessageResult {
|
|
48
|
+
signature: string;
|
|
49
|
+
}
|
|
50
|
+
interface BtcTransaction {
|
|
51
|
+
inputs: {
|
|
52
|
+
address: string;
|
|
53
|
+
amount: number;
|
|
54
|
+
asset: string;
|
|
55
|
+
nonce: number;
|
|
56
|
+
}[];
|
|
57
|
+
outputs: {
|
|
58
|
+
address: string;
|
|
59
|
+
amount: number;
|
|
60
|
+
asset: string;
|
|
61
|
+
}[];
|
|
62
|
+
fee: number;
|
|
63
|
+
}
|
|
64
|
+
interface SignedTransactionResult {
|
|
65
|
+
txid: string;
|
|
66
|
+
raw: string;
|
|
67
|
+
}
|
|
68
|
+
export interface Xverse {
|
|
69
|
+
connect: () => Promise<void>;
|
|
70
|
+
addListener: (event: string, callback: (...args: unknown[]) => void) => void;
|
|
71
|
+
createInscription: (data: InscriptionData) => Promise<InscriptionResult>;
|
|
72
|
+
createRepeatInscriptions: (data: RepeatInscriptionsData) => Promise<InscriptionResult[]>;
|
|
73
|
+
request: (method: string, params: unknown) => Promise<XverseRPCResponse>;
|
|
74
|
+
sendBtcTransaction: (transaction: BtcTransaction) => Promise<TransactionResult>;
|
|
75
|
+
signMessage: (message: string) => Promise<SignedMessageResult>;
|
|
76
|
+
signMultipleTransactions: (transactions: BtcTransaction[]) => Promise<SignedTransactionResult[]>;
|
|
77
|
+
signTransaction: (transaction: BtcTransaction) => Promise<SignedTransactionResult>;
|
|
78
|
+
}
|
|
79
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { i32 } from './types';
|
|
2
|
+
export declare const ADDRESS_BYTE_LENGTH: i32;
|
|
3
|
+
export declare const SELECTOR_BYTE_LENGTH: i32;
|
|
4
|
+
export declare const U256_BYTE_LENGTH: i32;
|
|
5
|
+
export declare const U128_BYTE_LENGTH: i32;
|
|
6
|
+
export declare const U64_BYTE_LENGTH: i32;
|
|
7
|
+
export declare const U32_BYTE_LENGTH: i32;
|
|
8
|
+
export declare const U16_BYTE_LENGTH: i32;
|
|
9
|
+
export declare const U8_BYTE_LENGTH: i32;
|
|
10
|
+
export declare const I256_BYTE_LENGTH: i32;
|
|
11
|
+
export declare const I128_BYTE_LENGTH: i32;
|
|
12
|
+
export declare const I64_BYTE_LENGTH: i32;
|
|
13
|
+
export declare const I32_BYTE_LENGTH: i32;
|
|
14
|
+
export declare const I16_BYTE_LENGTH: i32;
|
|
15
|
+
export declare const I8_BYTE_LENGTH: i32;
|
|
16
|
+
export declare const BOOLEAN_BYTE_LENGTH: i32;
|
package/browser/utils/types.d.ts
CHANGED
package/build/_version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.1.
|
|
1
|
+
export declare const version = "1.1.14";
|
package/build/_version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '1.1.
|
|
1
|
+
export const version = '1.1.14';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BufferLike, i32, Selector, u16, u32, u8 } from '../utils/types.js';
|
|
2
|
-
import { Address } from '../keypair/Address.js';
|
|
3
1
|
import { AddressMap } from '../deterministic/AddressMap.js';
|
|
2
|
+
import { Address } from '../keypair/Address.js';
|
|
3
|
+
import { BufferLike, i32, Selector, u16, u32, u8 } from '../utils/types.js';
|
|
4
4
|
export declare class BinaryReader {
|
|
5
5
|
private buffer;
|
|
6
6
|
private currentOffset;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ADDRESS_BYTE_LENGTH } from '../utils/types.js';
|
|
2
|
-
import { Address } from '../keypair/Address.js';
|
|
3
1
|
import { AddressMap } from '../deterministic/AddressMap.js';
|
|
2
|
+
import { Address } from '../keypair/Address.js';
|
|
3
|
+
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';
|
|
4
4
|
export class BinaryReader {
|
|
5
5
|
constructor(bytes) {
|
|
6
6
|
this.currentOffset = 0;
|
|
@@ -115,25 +115,27 @@ export class BinaryReader {
|
|
|
115
115
|
return result;
|
|
116
116
|
}
|
|
117
117
|
readU8() {
|
|
118
|
-
this.verifyEnd(this.currentOffset +
|
|
119
|
-
|
|
118
|
+
this.verifyEnd(this.currentOffset + U8_BYTE_LENGTH);
|
|
119
|
+
const value = this.buffer.getUint8(this.currentOffset);
|
|
120
|
+
this.currentOffset += U8_BYTE_LENGTH;
|
|
121
|
+
return value;
|
|
120
122
|
}
|
|
121
123
|
readU16() {
|
|
122
|
-
this.verifyEnd(this.currentOffset +
|
|
124
|
+
this.verifyEnd(this.currentOffset + U16_BYTE_LENGTH);
|
|
123
125
|
const value = this.buffer.getUint16(this.currentOffset, true);
|
|
124
|
-
this.currentOffset +=
|
|
126
|
+
this.currentOffset += U16_BYTE_LENGTH;
|
|
125
127
|
return value;
|
|
126
128
|
}
|
|
127
129
|
readU32(le = true) {
|
|
128
|
-
this.verifyEnd(this.currentOffset +
|
|
130
|
+
this.verifyEnd(this.currentOffset + U32_BYTE_LENGTH);
|
|
129
131
|
const value = this.buffer.getUint32(this.currentOffset, le);
|
|
130
|
-
this.currentOffset +=
|
|
132
|
+
this.currentOffset += U32_BYTE_LENGTH;
|
|
131
133
|
return value;
|
|
132
134
|
}
|
|
133
135
|
readU64() {
|
|
134
|
-
this.verifyEnd(this.currentOffset +
|
|
136
|
+
this.verifyEnd(this.currentOffset + U64_BYTE_LENGTH);
|
|
135
137
|
const value = this.buffer.getBigUint64(this.currentOffset, true);
|
|
136
|
-
this.currentOffset +=
|
|
138
|
+
this.currentOffset += U64_BYTE_LENGTH;
|
|
137
139
|
return value;
|
|
138
140
|
}
|
|
139
141
|
readAddressValueTuple() {
|
|
@@ -149,11 +151,11 @@ export class BinaryReader {
|
|
|
149
151
|
return result;
|
|
150
152
|
}
|
|
151
153
|
readU128() {
|
|
152
|
-
const next16Bytes = this.readBytes(
|
|
154
|
+
const next16Bytes = this.readBytes(U128_BYTE_LENGTH);
|
|
153
155
|
return BigInt('0x' + next16Bytes.reduce((acc, byte) => acc + byte.toString(16).padStart(2, '0'), ''));
|
|
154
156
|
}
|
|
155
157
|
readU256() {
|
|
156
|
-
const next32Bytes = this.readBytes(
|
|
158
|
+
const next32Bytes = this.readBytes(U256_BYTE_LENGTH);
|
|
157
159
|
return BigInt('0x' + next32Bytes.reduce((acc, byte) => acc + byte.toString(16).padStart(2, '0'), ''));
|
|
158
160
|
}
|
|
159
161
|
readBytes(length, zeroStop = false) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AddressMap } from '../deterministic/AddressMap.js';
|
|
2
2
|
import { Address } from '../keypair/Address.js';
|
|
3
|
+
import { Selector, u16, u32, u64, u8 } from '../utils/types.js';
|
|
3
4
|
import { BinaryReader } from './BinaryReader.js';
|
|
4
|
-
import { AddressMap } from '../deterministic/AddressMap.js';
|
|
5
5
|
export declare class BinaryWriter {
|
|
6
6
|
private currentOffset;
|
|
7
7
|
private buffer;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BufferHelper } from '../utils/BufferHelper.js';
|
|
2
|
-
import { ADDRESS_BYTE_LENGTH } from '../utils/
|
|
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';
|
|
3
3
|
import { BinaryReader } from './BinaryReader.js';
|
|
4
4
|
export class BinaryWriter {
|
|
5
5
|
constructor(length = 0) {
|
|
@@ -9,27 +9,27 @@ export class BinaryWriter {
|
|
|
9
9
|
writeU8(value) {
|
|
10
10
|
if (value > 255)
|
|
11
11
|
throw new Error('Value is too large.');
|
|
12
|
-
this.allocSafe(
|
|
12
|
+
this.allocSafe(U8_BYTE_LENGTH);
|
|
13
13
|
this.buffer.setUint8(this.currentOffset++, value);
|
|
14
14
|
}
|
|
15
15
|
writeU16(value) {
|
|
16
16
|
if (value > 65535)
|
|
17
17
|
throw new Error('Value is too large.');
|
|
18
|
-
this.allocSafe(
|
|
18
|
+
this.allocSafe(U16_BYTE_LENGTH);
|
|
19
19
|
this.buffer.setUint16(this.currentOffset, value, true);
|
|
20
20
|
this.currentOffset += 2;
|
|
21
21
|
}
|
|
22
22
|
writeU32(value, le = true) {
|
|
23
23
|
if (value > 4294967295)
|
|
24
24
|
throw new Error('Value is too large.');
|
|
25
|
-
this.allocSafe(
|
|
25
|
+
this.allocSafe(U32_BYTE_LENGTH);
|
|
26
26
|
this.buffer.setUint32(this.currentOffset, value, le);
|
|
27
27
|
this.currentOffset += 4;
|
|
28
28
|
}
|
|
29
29
|
writeU64(value) {
|
|
30
30
|
if (value > 18446744073709551615n)
|
|
31
31
|
throw new Error('Value is too large.');
|
|
32
|
-
this.allocSafe(
|
|
32
|
+
this.allocSafe(U64_BYTE_LENGTH);
|
|
33
33
|
this.buffer.setBigUint64(this.currentOffset, value, true);
|
|
34
34
|
this.currentOffset += 8;
|
|
35
35
|
}
|
|
@@ -44,9 +44,9 @@ export class BinaryWriter {
|
|
|
44
44
|
115792089237316195423570985008687907853269984665640564039457584007913129639935n) {
|
|
45
45
|
throw new Error('Value is too large.');
|
|
46
46
|
}
|
|
47
|
-
this.allocSafe(
|
|
47
|
+
this.allocSafe(U256_BYTE_LENGTH);
|
|
48
48
|
const bytesToHex = BufferHelper.valueToUint8Array(bigIntValue);
|
|
49
|
-
if (bytesToHex.byteLength !==
|
|
49
|
+
if (bytesToHex.byteLength !== U256_BYTE_LENGTH) {
|
|
50
50
|
throw new Error(`Invalid u256 value: ${bigIntValue}`);
|
|
51
51
|
}
|
|
52
52
|
for (let i = 0; i < bytesToHex.byteLength; i++) {
|
|
@@ -57,9 +57,9 @@ export class BinaryWriter {
|
|
|
57
57
|
if (bigIntValue > 340282366920938463463374607431768211455n) {
|
|
58
58
|
throw new Error('Value is too large.');
|
|
59
59
|
}
|
|
60
|
-
this.allocSafe(
|
|
61
|
-
const bytesToHex = BufferHelper.valueToUint8Array(bigIntValue,
|
|
62
|
-
if (bytesToHex.byteLength !==
|
|
60
|
+
this.allocSafe(U128_BYTE_LENGTH);
|
|
61
|
+
const bytesToHex = BufferHelper.valueToUint8Array(bigIntValue, U128_BYTE_LENGTH);
|
|
62
|
+
if (bytesToHex.byteLength !== U128_BYTE_LENGTH) {
|
|
63
63
|
throw new Error(`Invalid u128 value: ${bigIntValue}`);
|
|
64
64
|
}
|
|
65
65
|
for (let i = 0; i < bytesToHex.byteLength; i++) {
|
|
@@ -83,7 +83,7 @@ export class BinaryWriter {
|
|
|
83
83
|
this.writeBytes(value);
|
|
84
84
|
}
|
|
85
85
|
writeStringWithLength(value) {
|
|
86
|
-
this.allocSafe(value.length
|
|
86
|
+
this.allocSafe(U16_BYTE_LENGTH + value.length);
|
|
87
87
|
this.writeU16(value.length);
|
|
88
88
|
this.writeString(value);
|
|
89
89
|
}
|
|
@@ -101,7 +101,7 @@ export class BinaryWriter {
|
|
|
101
101
|
this.buffer = this.getDefaultBuffer(4);
|
|
102
102
|
}
|
|
103
103
|
writeTuple(values) {
|
|
104
|
-
this.allocSafe(
|
|
104
|
+
this.allocSafe(U32_BYTE_LENGTH + values.length * U256_BYTE_LENGTH);
|
|
105
105
|
this.writeU32(values.length);
|
|
106
106
|
for (let i = 0; i < values.length; i++) {
|
|
107
107
|
this.writeU256(values[i]);
|
package/build/keypair/Address.js
CHANGED
|
@@ -10,16 +10,17 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
10
10
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
11
|
};
|
|
12
12
|
var _Address_p2tr, _Address_network, _Address_originalPublicKey, _Address_keyPair;
|
|
13
|
-
import { EcKeyPair } from './EcKeyPair.js';
|
|
14
|
-
import { AddressVerificator } from './AddressVerificator.js';
|
|
15
13
|
import { toXOnly } from '@btc-vision/bitcoin/src/psbt/bip371.js';
|
|
14
|
+
import { ADDRESS_BYTE_LENGTH } from '../utils/lengths.js';
|
|
15
|
+
import { AddressVerificator } from './AddressVerificator.js';
|
|
16
|
+
import { EcKeyPair } from './EcKeyPair.js';
|
|
16
17
|
const hexPattern = /^[0-9a-fA-F]+$/;
|
|
17
18
|
const isHexadecimal = (input) => {
|
|
18
19
|
return hexPattern.test(input);
|
|
19
20
|
};
|
|
20
21
|
export class Address extends Uint8Array {
|
|
21
22
|
constructor(bytes) {
|
|
22
|
-
super(
|
|
23
|
+
super(ADDRESS_BYTE_LENGTH);
|
|
23
24
|
_Address_p2tr.set(this, void 0);
|
|
24
25
|
_Address_network.set(this, void 0);
|
|
25
26
|
_Address_originalPublicKey.set(this, void 0);
|
|
@@ -76,7 +77,7 @@ export class Address extends Uint8Array {
|
|
|
76
77
|
}
|
|
77
78
|
lessThan(a) {
|
|
78
79
|
const b = this;
|
|
79
|
-
for (let i = 0; i <
|
|
80
|
+
for (let i = 0; i < ADDRESS_BYTE_LENGTH; i++) {
|
|
80
81
|
const thisByte = b[i];
|
|
81
82
|
const aByte = a[i];
|
|
82
83
|
if (thisByte < aByte) {
|
|
@@ -90,7 +91,7 @@ export class Address extends Uint8Array {
|
|
|
90
91
|
}
|
|
91
92
|
greaterThan(a) {
|
|
92
93
|
const b = this;
|
|
93
|
-
for (let i = 0; i <
|
|
94
|
+
for (let i = 0; i < ADDRESS_BYTE_LENGTH; i++) {
|
|
94
95
|
const thisByte = b[i];
|
|
95
96
|
const aByte = a[i];
|
|
96
97
|
if (thisByte > aByte) {
|
|
@@ -103,11 +104,12 @@ export class Address extends Uint8Array {
|
|
|
103
104
|
return false;
|
|
104
105
|
}
|
|
105
106
|
set(publicKey) {
|
|
106
|
-
|
|
107
|
+
const validLengths = [ADDRESS_BYTE_LENGTH, 33, 65];
|
|
108
|
+
if (!validLengths.includes(publicKey.length)) {
|
|
107
109
|
throw new Error(`Invalid public key length ${publicKey.length}`);
|
|
108
110
|
}
|
|
109
|
-
if (publicKey.length ===
|
|
110
|
-
const buf = Buffer.alloc(
|
|
111
|
+
if (publicKey.length === ADDRESS_BYTE_LENGTH) {
|
|
112
|
+
const buf = Buffer.alloc(ADDRESS_BYTE_LENGTH);
|
|
111
113
|
buf.set(publicKey);
|
|
112
114
|
super.set(publicKey);
|
|
113
115
|
}
|
package/build/opnet.d.ts
CHANGED
|
@@ -1,57 +1,59 @@
|
|
|
1
1
|
export { version } from './_version.js';
|
|
2
2
|
export * from './bytecode/Compressor.js';
|
|
3
|
-
export * from './generators/Generator.js';
|
|
4
3
|
export * from './generators/builders/CalldataGenerator.js';
|
|
5
|
-
export * from './generators/builders/LegacyCalldataGenerator.js';
|
|
6
|
-
export * from './generators/builders/DeploymentGenerator.js';
|
|
7
4
|
export * from './generators/builders/CustomGenerator.js';
|
|
5
|
+
export * from './generators/builders/DeploymentGenerator.js';
|
|
6
|
+
export * from './generators/builders/LegacyCalldataGenerator.js';
|
|
8
7
|
export * from './generators/builders/MultiSignGenerator.js';
|
|
9
8
|
export * from './generators/Features.js';
|
|
9
|
+
export * from './generators/Generator.js';
|
|
10
10
|
export * from './generators/AddressGenerator.js';
|
|
11
11
|
export * from './verification/TapscriptVerificator.js';
|
|
12
|
+
export * from './keypair/AddressVerificator.js';
|
|
12
13
|
export * from './keypair/EcKeyPair.js';
|
|
13
|
-
export * from './keypair/Wallet.js';
|
|
14
14
|
export * from './keypair/interfaces/IWallet.js';
|
|
15
|
-
export * from './keypair/AddressVerificator.js';
|
|
16
15
|
export * from './keypair/MessageSigner.js';
|
|
16
|
+
export * from './keypair/Wallet.js';
|
|
17
17
|
export * from './metadata/ContractBaseMetadata.js';
|
|
18
18
|
export * from './network/ChainId.js';
|
|
19
19
|
export * from './signer/TweakedSigner.js';
|
|
20
|
-
export * from './transaction/
|
|
20
|
+
export * from './transaction/enums/TransactionType.js';
|
|
21
21
|
export * from './transaction/interfaces/ITransactionParameters.js';
|
|
22
22
|
export * from './transaction/interfaces/Tap.js';
|
|
23
|
-
export * from './transaction/
|
|
24
|
-
export * from './transaction/builders/InteractionTransaction.js';
|
|
25
|
-
export * from './transaction/builders/FundingTransaction.js';
|
|
26
|
-
export * from './transaction/builders/TransactionBuilder.js';
|
|
27
|
-
export * from './transaction/builders/SharedInteractionTransaction.js';
|
|
28
|
-
export * from './transaction/builders/DeploymentTransaction.js';
|
|
23
|
+
export * from './transaction/TransactionFactory.js';
|
|
29
24
|
export * from './transaction/builders/CustomScriptTransaction.js';
|
|
25
|
+
export * from './transaction/builders/DeploymentTransaction.js';
|
|
26
|
+
export * from './transaction/builders/FundingTransaction.js';
|
|
27
|
+
export * from './transaction/builders/InteractionTransaction.js';
|
|
30
28
|
export * from './transaction/builders/MultiSignTransaction.js';
|
|
29
|
+
export * from './transaction/builders/SharedInteractionTransaction.js';
|
|
30
|
+
export * from './transaction/builders/TransactionBuilder.js';
|
|
31
31
|
export * from './utils/BitcoinUtils.js';
|
|
32
32
|
export * from './utxo/interfaces/IUTXO.js';
|
|
33
33
|
export * from './utxo/OPNetLimitedProvider.js';
|
|
34
34
|
export * from './transaction/processor/PsbtTransaction.js';
|
|
35
|
+
export * from './transaction/psbt/PSBTTypes.js';
|
|
35
36
|
export * from './transaction/shared/TweakedTransaction.js';
|
|
36
37
|
export * from './utxo/interfaces/BroadcastResponse.js';
|
|
37
|
-
export * from './transaction/psbt/PSBTTypes.js';
|
|
38
38
|
export * from './transaction/shared/P2TR_MS.js';
|
|
39
|
-
export * from './consensus/ConsensusConfig.js';
|
|
40
39
|
export * from './consensus/Consensus.js';
|
|
40
|
+
export * from './consensus/ConsensusConfig.js';
|
|
41
41
|
export * from './consensus/metadata/RoswellConsensus.js';
|
|
42
|
-
export * from './utils/BufferHelper.js';
|
|
43
|
-
export * from './utils/types.js';
|
|
44
|
-
export * from './keypair/Address.js';
|
|
45
|
-
export * from './event/NetEvent.js';
|
|
46
|
-
export * from './deterministic/DeterministicMap.js';
|
|
47
|
-
export * from './deterministic/DeterministicSet.js';
|
|
48
|
-
export * from './deterministic/AddressMap.js';
|
|
49
|
-
export * from './deterministic/AddressSet.js';
|
|
50
42
|
export * from './abi/ABICoder.js';
|
|
51
|
-
export * from './buffer/BinaryWriter.js';
|
|
52
43
|
export * from './buffer/BinaryReader.js';
|
|
44
|
+
export * from './buffer/BinaryWriter.js';
|
|
45
|
+
export * from './deterministic/AddressMap.js';
|
|
46
|
+
export * from './deterministic/AddressSet.js';
|
|
47
|
+
export * from './deterministic/DeterministicMap.js';
|
|
48
|
+
export * from './deterministic/DeterministicSet.js';
|
|
49
|
+
export * from './event/NetEvent.js';
|
|
50
|
+
export * from './keypair/Address.js';
|
|
51
|
+
export * from './utils/BufferHelper.js';
|
|
52
|
+
export * from './utils/types.js';
|
|
53
53
|
export * from './transaction/browser/BrowserSignerBase.js';
|
|
54
54
|
export * from './transaction/browser/extensions/UnisatSigner.js';
|
|
55
|
+
export * from './transaction/browser/extensions/XverseSigner.js';
|
|
55
56
|
export * from './transaction/browser/types/Unisat.js';
|
|
56
|
-
export * from './transaction/browser/
|
|
57
|
+
export * from './transaction/browser/types/Xverse.js';
|
|
57
58
|
export * from './metadata/tokens.js';
|
|
59
|
+
export * from './transaction/browser/Web3Provider.js';
|
package/build/opnet.js
CHANGED
|
@@ -1,57 +1,59 @@
|
|
|
1
1
|
export { version } from './_version.js';
|
|
2
2
|
export * from './bytecode/Compressor.js';
|
|
3
|
-
export * from './generators/Generator.js';
|
|
4
3
|
export * from './generators/builders/CalldataGenerator.js';
|
|
5
|
-
export * from './generators/builders/LegacyCalldataGenerator.js';
|
|
6
|
-
export * from './generators/builders/DeploymentGenerator.js';
|
|
7
4
|
export * from './generators/builders/CustomGenerator.js';
|
|
5
|
+
export * from './generators/builders/DeploymentGenerator.js';
|
|
6
|
+
export * from './generators/builders/LegacyCalldataGenerator.js';
|
|
8
7
|
export * from './generators/builders/MultiSignGenerator.js';
|
|
9
8
|
export * from './generators/Features.js';
|
|
9
|
+
export * from './generators/Generator.js';
|
|
10
10
|
export * from './generators/AddressGenerator.js';
|
|
11
11
|
export * from './verification/TapscriptVerificator.js';
|
|
12
|
+
export * from './keypair/AddressVerificator.js';
|
|
12
13
|
export * from './keypair/EcKeyPair.js';
|
|
13
|
-
export * from './keypair/Wallet.js';
|
|
14
14
|
export * from './keypair/interfaces/IWallet.js';
|
|
15
|
-
export * from './keypair/AddressVerificator.js';
|
|
16
15
|
export * from './keypair/MessageSigner.js';
|
|
16
|
+
export * from './keypair/Wallet.js';
|
|
17
17
|
export * from './metadata/ContractBaseMetadata.js';
|
|
18
18
|
export * from './network/ChainId.js';
|
|
19
19
|
export * from './signer/TweakedSigner.js';
|
|
20
|
-
export * from './transaction/
|
|
20
|
+
export * from './transaction/enums/TransactionType.js';
|
|
21
21
|
export * from './transaction/interfaces/ITransactionParameters.js';
|
|
22
22
|
export * from './transaction/interfaces/Tap.js';
|
|
23
|
-
export * from './transaction/
|
|
24
|
-
export * from './transaction/builders/InteractionTransaction.js';
|
|
25
|
-
export * from './transaction/builders/FundingTransaction.js';
|
|
26
|
-
export * from './transaction/builders/TransactionBuilder.js';
|
|
27
|
-
export * from './transaction/builders/SharedInteractionTransaction.js';
|
|
28
|
-
export * from './transaction/builders/DeploymentTransaction.js';
|
|
23
|
+
export * from './transaction/TransactionFactory.js';
|
|
29
24
|
export * from './transaction/builders/CustomScriptTransaction.js';
|
|
25
|
+
export * from './transaction/builders/DeploymentTransaction.js';
|
|
26
|
+
export * from './transaction/builders/FundingTransaction.js';
|
|
27
|
+
export * from './transaction/builders/InteractionTransaction.js';
|
|
30
28
|
export * from './transaction/builders/MultiSignTransaction.js';
|
|
29
|
+
export * from './transaction/builders/SharedInteractionTransaction.js';
|
|
30
|
+
export * from './transaction/builders/TransactionBuilder.js';
|
|
31
31
|
export * from './utils/BitcoinUtils.js';
|
|
32
32
|
export * from './utxo/interfaces/IUTXO.js';
|
|
33
33
|
export * from './utxo/OPNetLimitedProvider.js';
|
|
34
34
|
export * from './transaction/processor/PsbtTransaction.js';
|
|
35
|
+
export * from './transaction/psbt/PSBTTypes.js';
|
|
35
36
|
export * from './transaction/shared/TweakedTransaction.js';
|
|
36
37
|
export * from './utxo/interfaces/BroadcastResponse.js';
|
|
37
|
-
export * from './transaction/psbt/PSBTTypes.js';
|
|
38
38
|
export * from './transaction/shared/P2TR_MS.js';
|
|
39
|
-
export * from './consensus/ConsensusConfig.js';
|
|
40
39
|
export * from './consensus/Consensus.js';
|
|
40
|
+
export * from './consensus/ConsensusConfig.js';
|
|
41
41
|
export * from './consensus/metadata/RoswellConsensus.js';
|
|
42
|
-
export * from './utils/BufferHelper.js';
|
|
43
|
-
export * from './utils/types.js';
|
|
44
|
-
export * from './keypair/Address.js';
|
|
45
|
-
export * from './event/NetEvent.js';
|
|
46
|
-
export * from './deterministic/DeterministicMap.js';
|
|
47
|
-
export * from './deterministic/DeterministicSet.js';
|
|
48
|
-
export * from './deterministic/AddressMap.js';
|
|
49
|
-
export * from './deterministic/AddressSet.js';
|
|
50
42
|
export * from './abi/ABICoder.js';
|
|
51
|
-
export * from './buffer/BinaryWriter.js';
|
|
52
43
|
export * from './buffer/BinaryReader.js';
|
|
44
|
+
export * from './buffer/BinaryWriter.js';
|
|
45
|
+
export * from './deterministic/AddressMap.js';
|
|
46
|
+
export * from './deterministic/AddressSet.js';
|
|
47
|
+
export * from './deterministic/DeterministicMap.js';
|
|
48
|
+
export * from './deterministic/DeterministicSet.js';
|
|
49
|
+
export * from './event/NetEvent.js';
|
|
50
|
+
export * from './keypair/Address.js';
|
|
51
|
+
export * from './utils/BufferHelper.js';
|
|
52
|
+
export * from './utils/types.js';
|
|
53
53
|
export * from './transaction/browser/BrowserSignerBase.js';
|
|
54
54
|
export * from './transaction/browser/extensions/UnisatSigner.js';
|
|
55
|
+
export * from './transaction/browser/extensions/XverseSigner.js';
|
|
55
56
|
export * from './transaction/browser/types/Unisat.js';
|
|
56
|
-
export * from './transaction/browser/
|
|
57
|
+
export * from './transaction/browser/types/Xverse.js';
|
|
57
58
|
export * from './metadata/tokens.js';
|
|
59
|
+
export * from './transaction/browser/Web3Provider.js';
|