@btc-vision/transaction 1.0.86 → 1.0.88
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/index.js +1 -1
- package/browser/transaction/builders/FundingTransaction.d.ts +2 -0
- package/browser/transaction/interfaces/ITransactionParameters.d.ts +2 -1
- package/build/_version.d.ts +1 -1
- package/build/_version.js +1 -1
- package/build/metadata/tokens.js +1 -1
- package/build/transaction/TransactionFactory.js +2 -0
- package/build/transaction/builders/FundingTransaction.d.ts +2 -0
- package/build/transaction/builders/FundingTransaction.js +23 -4
- package/build/transaction/builders/TransactionBuilder.js +2 -2
- package/build/transaction/interfaces/ITransactionParameters.d.ts +2 -1
- package/build/utxo/OPNetLimitedProvider.js +14 -19
- package/package.json +1 -1
- package/src/_version.ts +1 -1
- package/src/metadata/tokens.ts +135 -135
- package/src/transaction/TransactionFactory.ts +498 -496
- package/src/transaction/builders/FundingTransaction.ts +25 -4
- package/src/transaction/builders/TransactionBuilder.ts +2 -2
- package/src/transaction/interfaces/ITransactionParameters.ts +61 -59
- package/src/utxo/OPNetLimitedProvider.ts +244 -244
|
@@ -7,11 +7,13 @@ export class FundingTransaction extends TransactionBuilder<TransactionType.FUNDI
|
|
|
7
7
|
public readonly type: TransactionType.FUNDING = TransactionType.FUNDING;
|
|
8
8
|
|
|
9
9
|
protected childTransactionRequiredFees: bigint;
|
|
10
|
+
protected splitInputsInto: number;
|
|
10
11
|
|
|
11
12
|
constructor(parameters: IFundingTransactionParameters) {
|
|
12
13
|
super(parameters);
|
|
13
14
|
|
|
14
15
|
this.childTransactionRequiredFees = parameters.amount;
|
|
16
|
+
this.splitInputsInto = parameters.splitInputsInto ?? 1;
|
|
15
17
|
|
|
16
18
|
this.internalInit();
|
|
17
19
|
}
|
|
@@ -26,14 +28,33 @@ export class FundingTransaction extends TransactionBuilder<TransactionType.FUNDI
|
|
|
26
28
|
const amountSpent: bigint =
|
|
27
29
|
this.getTransactionOPNetFee() + this.childTransactionRequiredFees;
|
|
28
30
|
|
|
29
|
-
this.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
if(this.splitInputsInto > 1) {
|
|
32
|
+
await this.splitInputs(amountSpent);
|
|
33
|
+
} else {
|
|
34
|
+
this.addOutput({
|
|
35
|
+
value: Number(amountSpent),
|
|
36
|
+
address: this.to,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
33
39
|
|
|
34
40
|
await this.addRefundOutput(amountSpent);
|
|
35
41
|
}
|
|
36
42
|
|
|
43
|
+
protected async splitInputs(amountSpent: bigint): Promise<void> {
|
|
44
|
+
if (!this.to) {
|
|
45
|
+
throw new Error('Recipient address is required');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const splitAmount = amountSpent / BigInt(this.splitInputsInto);
|
|
49
|
+
|
|
50
|
+
for (let i = 0; i < this.splitInputsInto; i++) {
|
|
51
|
+
this.addOutput({
|
|
52
|
+
value: Number(splitAmount),
|
|
53
|
+
address: this.to,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
37
58
|
protected override getSignerKey(): Signer {
|
|
38
59
|
return this.signer;
|
|
39
60
|
}
|
|
@@ -115,7 +115,7 @@ export abstract class TransactionBuilder<T extends TransactionType> extends Twea
|
|
|
115
115
|
this.signer = parameters.signer;
|
|
116
116
|
this.network = parameters.network;
|
|
117
117
|
this.feeRate = parameters.feeRate;
|
|
118
|
-
this.priorityFee = parameters.priorityFee;
|
|
118
|
+
this.priorityFee = parameters.priorityFee ?? 0n;
|
|
119
119
|
this.utxos = parameters.utxos;
|
|
120
120
|
this.to = parameters.to || undefined;
|
|
121
121
|
|
|
@@ -192,7 +192,7 @@ export abstract class TransactionBuilder<T extends TransactionType> extends Twea
|
|
|
192
192
|
signer: this.signer,
|
|
193
193
|
network: this.network,
|
|
194
194
|
feeRate: this.feeRate,
|
|
195
|
-
priorityFee: this.priorityFee,
|
|
195
|
+
priorityFee: this.priorityFee ?? 0n,
|
|
196
196
|
from: this.from,
|
|
197
197
|
amount: this.estimatedFees,
|
|
198
198
|
};
|
|
@@ -1,59 +1,61 @@
|
|
|
1
|
-
import { UTXO } from '../../utxo/interfaces/IUTXO.js';
|
|
2
|
-
import { Address } from '@btc-vision/bsi-binary';
|
|
3
|
-
import { WrappedGeneration } from '../../wbtc/WrappedGenerationParameters.js';
|
|
4
|
-
import { ITweakedTransactionData } from '../shared/TweakedTransaction.js';
|
|
5
|
-
import { VaultUTXOs } from '../processor/PsbtTransaction.js';
|
|
6
|
-
import { ChainId } from '../../network/ChainId.js';
|
|
7
|
-
|
|
8
|
-
export interface ITransactionParameters extends ITweakedTransactionData {
|
|
9
|
-
readonly from?: Address;
|
|
10
|
-
readonly to?: Address | undefined;
|
|
11
|
-
utxos: UTXO[];
|
|
12
|
-
|
|
13
|
-
nonWitnessUtxo?: Buffer | undefined;
|
|
14
|
-
estimatedFees?: bigint;
|
|
15
|
-
|
|
16
|
-
chainId?: ChainId;
|
|
17
|
-
|
|
18
|
-
readonly feeRate: number;
|
|
19
|
-
readonly priorityFee
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface IFundingTransactionParameters extends ITransactionParameters {
|
|
23
|
-
amount: bigint;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
readonly
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
readonly
|
|
43
|
-
|
|
44
|
-
readonly
|
|
45
|
-
|
|
46
|
-
readonly
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
readonly
|
|
58
|
-
|
|
59
|
-
|
|
1
|
+
import { UTXO } from '../../utxo/interfaces/IUTXO.js';
|
|
2
|
+
import { Address } from '@btc-vision/bsi-binary';
|
|
3
|
+
import { WrappedGeneration } from '../../wbtc/WrappedGenerationParameters.js';
|
|
4
|
+
import { ITweakedTransactionData } from '../shared/TweakedTransaction.js';
|
|
5
|
+
import { VaultUTXOs } from '../processor/PsbtTransaction.js';
|
|
6
|
+
import { ChainId } from '../../network/ChainId.js';
|
|
7
|
+
|
|
8
|
+
export interface ITransactionParameters extends ITweakedTransactionData {
|
|
9
|
+
readonly from?: Address;
|
|
10
|
+
readonly to?: Address | undefined;
|
|
11
|
+
utxos: UTXO[];
|
|
12
|
+
|
|
13
|
+
nonWitnessUtxo?: Buffer | undefined;
|
|
14
|
+
estimatedFees?: bigint;
|
|
15
|
+
|
|
16
|
+
chainId?: ChainId;
|
|
17
|
+
|
|
18
|
+
readonly feeRate: number;
|
|
19
|
+
readonly priorityFee?: bigint;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface IFundingTransactionParameters extends ITransactionParameters {
|
|
23
|
+
amount: bigint;
|
|
24
|
+
|
|
25
|
+
splitInputsInto?: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface SharedInteractionParameters extends ITransactionParameters {
|
|
29
|
+
calldata?: Buffer | undefined;
|
|
30
|
+
disableAutoRefund?: boolean;
|
|
31
|
+
|
|
32
|
+
readonly randomBytes?: Buffer;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface IInteractionParameters extends SharedInteractionParameters {
|
|
36
|
+
readonly calldata: Buffer;
|
|
37
|
+
|
|
38
|
+
readonly to: Address;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface IWrapParameters extends SharedInteractionParameters {
|
|
42
|
+
readonly to?: Address;
|
|
43
|
+
|
|
44
|
+
readonly from: Address;
|
|
45
|
+
readonly amount: bigint;
|
|
46
|
+
readonly receiver?: Address;
|
|
47
|
+
|
|
48
|
+
readonly generationParameters: WrappedGeneration;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface IUnwrapParameters extends SharedInteractionParameters {
|
|
52
|
+
readonly unwrapUTXOs: VaultUTXOs[];
|
|
53
|
+
readonly amount: bigint;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface IDeploymentParameters extends ITransactionParameters {
|
|
57
|
+
readonly bytecode: Buffer;
|
|
58
|
+
|
|
59
|
+
readonly to?: undefined;
|
|
60
|
+
readonly randomBytes?: Buffer;
|
|
61
|
+
}
|