@btc-vision/transaction 1.1.12 → 1.1.14
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/transaction/builders/TransactionBuilder.d.ts +1 -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 +12 -12
- package/build/buffer/BinaryWriter.d.ts +2 -2
- package/build/buffer/BinaryWriter.js +12 -12
- package/build/deterministic/AddressMap.js +1 -1
- 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 +17 -5
- 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/transaction/builders/CustomScriptTransaction.js +1 -1
- package/build/transaction/builders/DeploymentTransaction.js +1 -1
- package/build/transaction/builders/FundingTransaction.js +1 -1
- package/build/transaction/builders/SharedInteractionTransaction.js +2 -1
- package/build/transaction/builders/TransactionBuilder.d.ts +1 -0
- package/build/transaction/builders/TransactionBuilder.js +10 -1
- 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 +21 -12
- package/src/buffer/BinaryWriter.ts +23 -15
- package/src/deterministic/AddressMap.ts +1 -1
- package/src/keypair/Address.ts +11 -9
- package/src/opnet.ts +26 -24
- package/src/transaction/TransactionFactory.ts +18 -6
- package/src/transaction/browser/extensions/XverseSigner.ts +429 -0
- package/src/transaction/browser/types/Xverse.ts +104 -0
- package/src/transaction/builders/CustomScriptTransaction.ts +1 -1
- package/src/transaction/builders/DeploymentTransaction.ts +1 -1
- package/src/transaction/builders/FundingTransaction.ts +1 -1
- package/src/transaction/builders/SharedInteractionTransaction.ts +2 -1
- package/src/transaction/builders/TransactionBuilder.ts +12 -2
- package/src/utils/BufferHelper.ts +2 -1
- package/src/utils/lengths.ts +20 -0
- package/src/utils/types.ts +0 -2
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
import { ADDRESS_BYTE_LENGTH, 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 {
|
|
4
|
+
ADDRESS_BYTE_LENGTH,
|
|
5
|
+
U128_BYTE_LENGTH,
|
|
6
|
+
U16_BYTE_LENGTH,
|
|
7
|
+
U256_BYTE_LENGTH,
|
|
8
|
+
U32_BYTE_LENGTH,
|
|
9
|
+
U64_BYTE_LENGTH,
|
|
10
|
+
U8_BYTE_LENGTH,
|
|
11
|
+
} from '../utils/lengths.js';
|
|
12
|
+
import { BufferLike, i32, Selector, u16, u32, u8 } from '../utils/types.js';
|
|
4
13
|
|
|
5
14
|
export class BinaryReader {
|
|
6
15
|
private buffer: DataView;
|
|
@@ -154,34 +163,34 @@ export class BinaryReader {
|
|
|
154
163
|
}
|
|
155
164
|
|
|
156
165
|
public readU8(): u8 {
|
|
157
|
-
this.verifyEnd(this.currentOffset +
|
|
166
|
+
this.verifyEnd(this.currentOffset + U8_BYTE_LENGTH);
|
|
158
167
|
|
|
159
|
-
return this.buffer.getUint8(this.currentOffset
|
|
168
|
+
return this.buffer.getUint8(this.currentOffset + U8_BYTE_LENGTH);
|
|
160
169
|
}
|
|
161
170
|
|
|
162
171
|
public readU16(): u16 {
|
|
163
|
-
this.verifyEnd(this.currentOffset +
|
|
172
|
+
this.verifyEnd(this.currentOffset + U16_BYTE_LENGTH);
|
|
164
173
|
|
|
165
174
|
const value = this.buffer.getUint16(this.currentOffset, true);
|
|
166
|
-
this.currentOffset +=
|
|
175
|
+
this.currentOffset += U16_BYTE_LENGTH;
|
|
167
176
|
|
|
168
177
|
return value;
|
|
169
178
|
}
|
|
170
179
|
|
|
171
180
|
public readU32(le: boolean = true): u32 {
|
|
172
|
-
this.verifyEnd(this.currentOffset +
|
|
181
|
+
this.verifyEnd(this.currentOffset + U32_BYTE_LENGTH);
|
|
173
182
|
|
|
174
183
|
const value = this.buffer.getUint32(this.currentOffset, le);
|
|
175
|
-
this.currentOffset +=
|
|
184
|
+
this.currentOffset += U32_BYTE_LENGTH;
|
|
176
185
|
|
|
177
186
|
return value;
|
|
178
187
|
}
|
|
179
188
|
|
|
180
189
|
public readU64(): bigint {
|
|
181
|
-
this.verifyEnd(this.currentOffset +
|
|
190
|
+
this.verifyEnd(this.currentOffset + U64_BYTE_LENGTH);
|
|
182
191
|
|
|
183
192
|
const value: bigint = this.buffer.getBigUint64(this.currentOffset, true);
|
|
184
|
-
this.currentOffset +=
|
|
193
|
+
this.currentOffset += U64_BYTE_LENGTH;
|
|
185
194
|
|
|
186
195
|
return value;
|
|
187
196
|
}
|
|
@@ -203,7 +212,7 @@ export class BinaryReader {
|
|
|
203
212
|
}
|
|
204
213
|
|
|
205
214
|
public readU128(): bigint {
|
|
206
|
-
const next16Bytes = this.readBytes(
|
|
215
|
+
const next16Bytes = this.readBytes(U128_BYTE_LENGTH);
|
|
207
216
|
|
|
208
217
|
return BigInt(
|
|
209
218
|
'0x' + next16Bytes.reduce((acc, byte) => acc + byte.toString(16).padStart(2, '0'), ''),
|
|
@@ -211,7 +220,7 @@ export class BinaryReader {
|
|
|
211
220
|
}
|
|
212
221
|
|
|
213
222
|
public readU256(): bigint {
|
|
214
|
-
const next32Bytes = this.readBytes(
|
|
223
|
+
const next32Bytes = this.readBytes(U256_BYTE_LENGTH);
|
|
215
224
|
|
|
216
225
|
return BigInt(
|
|
217
226
|
'0x' + next32Bytes.reduce((acc, byte) => acc + byte.toString(16).padStart(2, '0'), ''),
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ADDRESS_BYTE_LENGTH, i32, Selector, u16, u32, u64, u8 } from '../utils/types.js';
|
|
1
|
+
import { AddressMap } from '../deterministic/AddressMap.js';
|
|
3
2
|
import { Address } from '../keypair/Address.js';
|
|
3
|
+
import { BufferHelper } from '../utils/BufferHelper.js';
|
|
4
|
+
import {
|
|
5
|
+
ADDRESS_BYTE_LENGTH,
|
|
6
|
+
U128_BYTE_LENGTH,
|
|
7
|
+
U16_BYTE_LENGTH,
|
|
8
|
+
U256_BYTE_LENGTH,
|
|
9
|
+
U32_BYTE_LENGTH,
|
|
10
|
+
U64_BYTE_LENGTH,
|
|
11
|
+
U8_BYTE_LENGTH,
|
|
12
|
+
} from '../utils/lengths.js';
|
|
13
|
+
import { i32, Selector, u16, u32, u64, u8 } from '../utils/types.js';
|
|
4
14
|
import { BinaryReader } from './BinaryReader.js';
|
|
5
|
-
import { AddressMap } from '../deterministic/AddressMap.js';
|
|
6
15
|
|
|
7
16
|
export class BinaryWriter {
|
|
8
17
|
private currentOffset: u32 = 0;
|
|
@@ -15,14 +24,14 @@ export class BinaryWriter {
|
|
|
15
24
|
public writeU8(value: u8): void {
|
|
16
25
|
if (value > 255) throw new Error('Value is too large.');
|
|
17
26
|
|
|
18
|
-
this.allocSafe(
|
|
27
|
+
this.allocSafe(U8_BYTE_LENGTH);
|
|
19
28
|
this.buffer.setUint8(this.currentOffset++, value);
|
|
20
29
|
}
|
|
21
30
|
|
|
22
31
|
public writeU16(value: u16): void {
|
|
23
32
|
if (value > 65535) throw new Error('Value is too large.');
|
|
24
33
|
|
|
25
|
-
this.allocSafe(
|
|
34
|
+
this.allocSafe(U16_BYTE_LENGTH);
|
|
26
35
|
this.buffer.setUint16(this.currentOffset, value, true);
|
|
27
36
|
this.currentOffset += 2;
|
|
28
37
|
}
|
|
@@ -30,7 +39,7 @@ export class BinaryWriter {
|
|
|
30
39
|
public writeU32(value: u32, le: boolean = true): void {
|
|
31
40
|
if (value > 4294967295) throw new Error('Value is too large.');
|
|
32
41
|
|
|
33
|
-
this.allocSafe(
|
|
42
|
+
this.allocSafe(U32_BYTE_LENGTH);
|
|
34
43
|
this.buffer.setUint32(this.currentOffset, value, le);
|
|
35
44
|
this.currentOffset += 4;
|
|
36
45
|
}
|
|
@@ -38,7 +47,7 @@ export class BinaryWriter {
|
|
|
38
47
|
public writeU64(value: u64): void {
|
|
39
48
|
if (value > 18446744073709551615n) throw new Error('Value is too large.');
|
|
40
49
|
|
|
41
|
-
this.allocSafe(
|
|
50
|
+
this.allocSafe(U64_BYTE_LENGTH);
|
|
42
51
|
this.buffer.setBigUint64(this.currentOffset, value, true);
|
|
43
52
|
this.currentOffset += 8;
|
|
44
53
|
}
|
|
@@ -59,10 +68,10 @@ export class BinaryWriter {
|
|
|
59
68
|
throw new Error('Value is too large.');
|
|
60
69
|
}
|
|
61
70
|
|
|
62
|
-
this.allocSafe(
|
|
71
|
+
this.allocSafe(U256_BYTE_LENGTH);
|
|
63
72
|
|
|
64
73
|
const bytesToHex = BufferHelper.valueToUint8Array(bigIntValue);
|
|
65
|
-
if (bytesToHex.byteLength !==
|
|
74
|
+
if (bytesToHex.byteLength !== U256_BYTE_LENGTH) {
|
|
66
75
|
throw new Error(`Invalid u256 value: ${bigIntValue}`);
|
|
67
76
|
}
|
|
68
77
|
|
|
@@ -76,10 +85,10 @@ export class BinaryWriter {
|
|
|
76
85
|
throw new Error('Value is too large.');
|
|
77
86
|
}
|
|
78
87
|
|
|
79
|
-
this.allocSafe(
|
|
88
|
+
this.allocSafe(U128_BYTE_LENGTH);
|
|
80
89
|
|
|
81
|
-
const bytesToHex = BufferHelper.valueToUint8Array(bigIntValue,
|
|
82
|
-
if (bytesToHex.byteLength !==
|
|
90
|
+
const bytesToHex = BufferHelper.valueToUint8Array(bigIntValue, U128_BYTE_LENGTH);
|
|
91
|
+
if (bytesToHex.byteLength !== U128_BYTE_LENGTH) {
|
|
83
92
|
throw new Error(`Invalid u128 value: ${bigIntValue}`);
|
|
84
93
|
}
|
|
85
94
|
|
|
@@ -111,7 +120,7 @@ export class BinaryWriter {
|
|
|
111
120
|
}
|
|
112
121
|
|
|
113
122
|
public writeStringWithLength(value: string): void {
|
|
114
|
-
this.allocSafe(value.length
|
|
123
|
+
this.allocSafe(U16_BYTE_LENGTH + value.length);
|
|
115
124
|
|
|
116
125
|
this.writeU16(value.length);
|
|
117
126
|
this.writeString(value);
|
|
@@ -134,7 +143,7 @@ export class BinaryWriter {
|
|
|
134
143
|
}
|
|
135
144
|
|
|
136
145
|
public writeTuple(values: bigint[]): void {
|
|
137
|
-
this.allocSafe(
|
|
146
|
+
this.allocSafe(U32_BYTE_LENGTH + values.length * U256_BYTE_LENGTH);
|
|
138
147
|
this.writeU32(values.length);
|
|
139
148
|
|
|
140
149
|
for (let i = 0; i < values.length; i++) {
|
|
@@ -248,7 +257,6 @@ export class BinaryWriter {
|
|
|
248
257
|
if (value.length > 65535) throw new Error('Array size is too large');
|
|
249
258
|
|
|
250
259
|
this.writeU16(value.length);
|
|
251
|
-
|
|
252
260
|
for (let i = 0; i < value.length; i++) {
|
|
253
261
|
this.writeU128(value[i]);
|
|
254
262
|
}
|
|
@@ -4,7 +4,7 @@ import { Map } from './Map.js';
|
|
|
4
4
|
|
|
5
5
|
export class AddressMap<V> extends Map<Address, V> {
|
|
6
6
|
public set(key: Address, value: V): void {
|
|
7
|
-
const index: i32 = this.
|
|
7
|
+
const index: i32 = this.indexOf(key);
|
|
8
8
|
if (index == -1) {
|
|
9
9
|
this._keys.push(key);
|
|
10
10
|
this._values.push(value);
|
package/src/keypair/Address.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Network } from '@btc-vision/bitcoin';
|
|
2
|
-
import {
|
|
2
|
+
import { toXOnly } from '@btc-vision/bitcoin/src/psbt/bip371.js';
|
|
3
3
|
import { ECPairInterface } from 'ecpair';
|
|
4
|
+
import { ADDRESS_BYTE_LENGTH } from '../utils/lengths.js';
|
|
4
5
|
import { AddressVerificator } from './AddressVerificator.js';
|
|
5
|
-
import {
|
|
6
|
+
import { EcKeyPair } from './EcKeyPair.js';
|
|
6
7
|
|
|
7
8
|
const hexPattern = /^[0-9a-fA-F]+$/;
|
|
8
9
|
const isHexadecimal = (input: string): boolean => {
|
|
@@ -20,7 +21,7 @@ export class Address extends Uint8Array {
|
|
|
20
21
|
#keyPair: ECPairInterface | undefined;
|
|
21
22
|
|
|
22
23
|
public constructor(bytes?: ArrayLike<number>) {
|
|
23
|
-
super(
|
|
24
|
+
super(ADDRESS_BYTE_LENGTH);
|
|
24
25
|
|
|
25
26
|
if (!bytes) {
|
|
26
27
|
return;
|
|
@@ -126,7 +127,7 @@ export class Address extends Uint8Array {
|
|
|
126
127
|
public lessThan(a: Address): boolean {
|
|
127
128
|
const b: Address = this as Address;
|
|
128
129
|
|
|
129
|
-
for (let i = 0; i <
|
|
130
|
+
for (let i = 0; i < ADDRESS_BYTE_LENGTH; i++) {
|
|
130
131
|
const thisByte = b[i];
|
|
131
132
|
const aByte = a[i];
|
|
132
133
|
|
|
@@ -148,7 +149,7 @@ export class Address extends Uint8Array {
|
|
|
148
149
|
// Compare the two addresses byte-by-byte, treating them as big-endian uint256
|
|
149
150
|
const b = this as Address;
|
|
150
151
|
|
|
151
|
-
for (let i = 0; i <
|
|
152
|
+
for (let i = 0; i < ADDRESS_BYTE_LENGTH; i++) {
|
|
152
153
|
const thisByte = b[i];
|
|
153
154
|
const aByte = a[i];
|
|
154
155
|
|
|
@@ -168,12 +169,13 @@ export class Address extends Uint8Array {
|
|
|
168
169
|
* @returns {void}
|
|
169
170
|
*/
|
|
170
171
|
public override set(publicKey: ArrayLike<number>): void {
|
|
171
|
-
|
|
172
|
+
const validLengths = [ADDRESS_BYTE_LENGTH, 33, 65];
|
|
173
|
+
if (!validLengths.includes(publicKey.length)) {
|
|
172
174
|
throw new Error(`Invalid public key length ${publicKey.length}`);
|
|
173
175
|
}
|
|
174
176
|
|
|
175
|
-
if (publicKey.length ===
|
|
176
|
-
const buf = Buffer.alloc(
|
|
177
|
+
if (publicKey.length === ADDRESS_BYTE_LENGTH) {
|
|
178
|
+
const buf = Buffer.alloc(ADDRESS_BYTE_LENGTH);
|
|
177
179
|
buf.set(publicKey);
|
|
178
180
|
|
|
179
181
|
super.set(publicKey);
|
|
@@ -228,7 +230,7 @@ export class Address extends Uint8Array {
|
|
|
228
230
|
public toString(): string {
|
|
229
231
|
return this.toHex();
|
|
230
232
|
}
|
|
231
|
-
|
|
233
|
+
|
|
232
234
|
/**
|
|
233
235
|
* Convert the address to a JSON string
|
|
234
236
|
*/
|
package/src/opnet.ts
CHANGED
|
@@ -4,24 +4,24 @@ export { version } from './_version.js';
|
|
|
4
4
|
export * from './bytecode/Compressor.js';
|
|
5
5
|
|
|
6
6
|
/** Generators */
|
|
7
|
-
export * from './generators/Generator.js';
|
|
8
7
|
export * from './generators/builders/CalldataGenerator.js';
|
|
9
|
-
export * from './generators/builders/LegacyCalldataGenerator.js';
|
|
10
|
-
export * from './generators/builders/DeploymentGenerator.js';
|
|
11
8
|
export * from './generators/builders/CustomGenerator.js';
|
|
9
|
+
export * from './generators/builders/DeploymentGenerator.js';
|
|
10
|
+
export * from './generators/builders/LegacyCalldataGenerator.js';
|
|
12
11
|
export * from './generators/builders/MultiSignGenerator.js';
|
|
13
12
|
export * from './generators/Features.js';
|
|
13
|
+
export * from './generators/Generator.js';
|
|
14
14
|
|
|
15
15
|
/** Address */
|
|
16
16
|
export * from './generators/AddressGenerator.js';
|
|
17
17
|
export * from './verification/TapscriptVerificator.js';
|
|
18
18
|
|
|
19
19
|
/** Key Pair */
|
|
20
|
+
export * from './keypair/AddressVerificator.js';
|
|
20
21
|
export * from './keypair/EcKeyPair.js';
|
|
21
|
-
export * from './keypair/Wallet.js';
|
|
22
22
|
export * from './keypair/interfaces/IWallet.js';
|
|
23
|
-
export * from './keypair/AddressVerificator.js';
|
|
24
23
|
export * from './keypair/MessageSigner.js';
|
|
24
|
+
export * from './keypair/Wallet.js';
|
|
25
25
|
|
|
26
26
|
/** Metadata */
|
|
27
27
|
export * from './metadata/ContractBaseMetadata.js';
|
|
@@ -31,19 +31,19 @@ export * from './network/ChainId.js';
|
|
|
31
31
|
export * from './signer/TweakedSigner.js';
|
|
32
32
|
|
|
33
33
|
/** Transaction */
|
|
34
|
-
export * from './transaction/
|
|
34
|
+
export * from './transaction/enums/TransactionType.js';
|
|
35
35
|
export * from './transaction/interfaces/ITransactionParameters.js';
|
|
36
36
|
export * from './transaction/interfaces/Tap.js';
|
|
37
|
-
export * from './transaction/
|
|
37
|
+
export * from './transaction/TransactionFactory.js';
|
|
38
38
|
|
|
39
39
|
/** Builders */
|
|
40
|
-
export * from './transaction/builders/InteractionTransaction.js';
|
|
41
|
-
export * from './transaction/builders/FundingTransaction.js';
|
|
42
|
-
export * from './transaction/builders/TransactionBuilder.js';
|
|
43
|
-
export * from './transaction/builders/SharedInteractionTransaction.js';
|
|
44
|
-
export * from './transaction/builders/DeploymentTransaction.js';
|
|
45
40
|
export * from './transaction/builders/CustomScriptTransaction.js';
|
|
41
|
+
export * from './transaction/builders/DeploymentTransaction.js';
|
|
42
|
+
export * from './transaction/builders/FundingTransaction.js';
|
|
43
|
+
export * from './transaction/builders/InteractionTransaction.js';
|
|
46
44
|
export * from './transaction/builders/MultiSignTransaction.js';
|
|
45
|
+
export * from './transaction/builders/SharedInteractionTransaction.js';
|
|
46
|
+
export * from './transaction/builders/TransactionBuilder.js';
|
|
47
47
|
|
|
48
48
|
/** Utils */
|
|
49
49
|
export * from './utils/BitcoinUtils.js';
|
|
@@ -56,34 +56,36 @@ export * from './utxo/OPNetLimitedProvider.js';
|
|
|
56
56
|
export * from './transaction/processor/PsbtTransaction.js';
|
|
57
57
|
|
|
58
58
|
/** Shared */
|
|
59
|
+
export * from './transaction/psbt/PSBTTypes.js';
|
|
59
60
|
export * from './transaction/shared/TweakedTransaction.js';
|
|
60
61
|
export * from './utxo/interfaces/BroadcastResponse.js';
|
|
61
|
-
export * from './transaction/psbt/PSBTTypes.js';
|
|
62
62
|
|
|
63
63
|
export * from './transaction/shared/P2TR_MS.js';
|
|
64
64
|
|
|
65
65
|
/** Consensus */
|
|
66
|
-
export * from './consensus/ConsensusConfig.js';
|
|
67
66
|
export * from './consensus/Consensus.js';
|
|
67
|
+
export * from './consensus/ConsensusConfig.js';
|
|
68
68
|
export * from './consensus/metadata/RoswellConsensus.js';
|
|
69
69
|
|
|
70
70
|
/** Binary */
|
|
71
|
-
export * from './utils/BufferHelper.js';
|
|
72
|
-
export * from './utils/types.js';
|
|
73
|
-
export * from './keypair/Address.js';
|
|
74
|
-
export * from './event/NetEvent.js';
|
|
75
|
-
export * from './deterministic/DeterministicMap.js';
|
|
76
|
-
export * from './deterministic/DeterministicSet.js';
|
|
77
|
-
export * from './deterministic/AddressMap.js';
|
|
78
|
-
export * from './deterministic/AddressSet.js';
|
|
79
71
|
export * from './abi/ABICoder.js';
|
|
80
|
-
export * from './buffer/BinaryWriter.js';
|
|
81
72
|
export * from './buffer/BinaryReader.js';
|
|
73
|
+
export * from './buffer/BinaryWriter.js';
|
|
74
|
+
export * from './deterministic/AddressMap.js';
|
|
75
|
+
export * from './deterministic/AddressSet.js';
|
|
76
|
+
export * from './deterministic/DeterministicMap.js';
|
|
77
|
+
export * from './deterministic/DeterministicSet.js';
|
|
78
|
+
export * from './event/NetEvent.js';
|
|
79
|
+
export * from './keypair/Address.js';
|
|
80
|
+
export * from './utils/BufferHelper.js';
|
|
81
|
+
export * from './utils/types.js';
|
|
82
82
|
|
|
83
83
|
/** Custom signers */
|
|
84
84
|
export * from './transaction/browser/BrowserSignerBase.js';
|
|
85
85
|
export * from './transaction/browser/extensions/UnisatSigner.js';
|
|
86
|
+
export * from './transaction/browser/extensions/XverseSigner.js';
|
|
86
87
|
export * from './transaction/browser/types/Unisat.js';
|
|
88
|
+
export * from './transaction/browser/types/Xverse.js';
|
|
87
89
|
|
|
88
|
-
export * from './transaction/browser/Web3Provider.js';
|
|
89
90
|
export * from './metadata/tokens.js';
|
|
91
|
+
export * from './transaction/browser/Web3Provider.js';
|
|
@@ -91,7 +91,8 @@ export class TransactionFactory {
|
|
|
91
91
|
parameters.utxos = interactionParameters.utxos;
|
|
92
92
|
parameters.amount =
|
|
93
93
|
(await preTransaction.estimateTransactionFees()) +
|
|
94
|
-
this.getPriorityFee(interactionParameters)
|
|
94
|
+
this.getPriorityFee(interactionParameters) +
|
|
95
|
+
preTransaction.getOptionalOutputValue();
|
|
95
96
|
|
|
96
97
|
const feeEstimationFundingTransaction = await this.createFundTransaction({ ...parameters });
|
|
97
98
|
if (!feeEstimationFundingTransaction) {
|
|
@@ -145,13 +146,16 @@ export class TransactionFactory {
|
|
|
145
146
|
throw new Error('Field "from" not provided.');
|
|
146
147
|
}
|
|
147
148
|
|
|
149
|
+
if (!interactionParameters.utxos[0]) {
|
|
150
|
+
throw new Error('Missing at least one UTXO.');
|
|
151
|
+
}
|
|
152
|
+
|
|
148
153
|
const preTransaction: InteractionTransaction = new InteractionTransaction({
|
|
149
154
|
...interactionParameters,
|
|
150
155
|
utxos: [interactionParameters.utxos[0]], // we simulate one input here.
|
|
151
156
|
});
|
|
152
157
|
|
|
153
158
|
// we don't sign that transaction, we just need the parameters.
|
|
154
|
-
|
|
155
159
|
await preTransaction.generateTransactionMinimalSignatures();
|
|
156
160
|
|
|
157
161
|
const parameters: IFundingTransactionParameters =
|
|
@@ -160,16 +164,23 @@ export class TransactionFactory {
|
|
|
160
164
|
parameters.utxos = interactionParameters.utxos;
|
|
161
165
|
parameters.amount =
|
|
162
166
|
(await preTransaction.estimateTransactionFees()) +
|
|
163
|
-
this.getPriorityFee(interactionParameters)
|
|
167
|
+
this.getPriorityFee(interactionParameters) +
|
|
168
|
+
preTransaction.getOptionalOutputValue();
|
|
164
169
|
|
|
165
|
-
const feeEstimationFundingTransaction = await this.createFundTransaction({
|
|
170
|
+
const feeEstimationFundingTransaction = await this.createFundTransaction({
|
|
171
|
+
...parameters,
|
|
172
|
+
optionalOutputs: [],
|
|
173
|
+
});
|
|
166
174
|
if (!feeEstimationFundingTransaction) {
|
|
167
175
|
throw new Error('Could not sign funding transaction.');
|
|
168
176
|
}
|
|
169
177
|
|
|
170
178
|
parameters.estimatedFees = feeEstimationFundingTransaction.estimatedFees;
|
|
171
179
|
|
|
172
|
-
const signedTransaction = await this.createFundTransaction(
|
|
180
|
+
const signedTransaction = await this.createFundTransaction({
|
|
181
|
+
...parameters,
|
|
182
|
+
optionalOutputs: [],
|
|
183
|
+
});
|
|
173
184
|
if (!signedTransaction) {
|
|
174
185
|
throw new Error('Could not sign funding transaction.');
|
|
175
186
|
}
|
|
@@ -219,7 +230,8 @@ export class TransactionFactory {
|
|
|
219
230
|
|
|
220
231
|
parameters.amount =
|
|
221
232
|
(await preTransaction.estimateTransactionFees()) +
|
|
222
|
-
this.getPriorityFee(deploymentParameters)
|
|
233
|
+
this.getPriorityFee(deploymentParameters) +
|
|
234
|
+
preTransaction.getOptionalOutputValue();
|
|
223
235
|
|
|
224
236
|
const fundingTransaction: FundingTransaction = new FundingTransaction(parameters);
|
|
225
237
|
const signedTransaction: Transaction = await fundingTransaction.signTransaction();
|