@btc-vision/transaction 1.0.91 → 1.0.92

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.
@@ -40,7 +40,7 @@ export declare class TransactionFactory {
40
40
  constructor();
41
41
  signInteraction(interactionParameters: IInteractionParameters): Promise<[string, string, UTXO[]]>;
42
42
  signDeployment(deploymentParameters: IDeploymentParameters): Promise<DeploymentResult>;
43
- wrap(warpParameters: Omit<IWrapParameters, 'calldata'>): Promise<WrapResult>;
43
+ wrap(wrapParameters: Omit<IWrapParameters, 'calldata'>): Promise<WrapResult>;
44
44
  unwrapSegwit(unwrapParameters: IUnwrapParameters): Promise<UnwrapResult>;
45
45
  unwrap(unwrapParameters: IUnwrapParameters): Promise<UnwrapResult>;
46
46
  createBTCTransfer(parameters: IFundingTransactionParameters): Promise<BitcoinTransferResponse>;
@@ -13,7 +13,7 @@ export interface ITransactionParameters extends ITweakedTransactionData {
13
13
  estimatedFees?: bigint;
14
14
  chainId?: ChainId;
15
15
  readonly feeRate: number;
16
- readonly priorityFee?: bigint;
16
+ readonly priorityFee: bigint;
17
17
  }
18
18
  export interface IFundingTransactionParameters extends ITransactionParameters {
19
19
  amount: bigint;
@@ -1 +1 @@
1
- export declare const version = "1.0.91";
1
+ export declare const version = "1.0.92";
package/build/_version.js CHANGED
@@ -1 +1 @@
1
- export const version = '1.0.91';
1
+ export const version = '1.0.92';
@@ -40,7 +40,7 @@ export declare class TransactionFactory {
40
40
  constructor();
41
41
  signInteraction(interactionParameters: IInteractionParameters): Promise<[string, string, UTXO[]]>;
42
42
  signDeployment(deploymentParameters: IDeploymentParameters): Promise<DeploymentResult>;
43
- wrap(warpParameters: Omit<IWrapParameters, 'calldata'>): Promise<WrapResult>;
43
+ wrap(wrapParameters: Omit<IWrapParameters, 'calldata'>): Promise<WrapResult>;
44
44
  unwrapSegwit(unwrapParameters: IUnwrapParameters): Promise<UnwrapResult>;
45
45
  unwrap(unwrapParameters: IUnwrapParameters): Promise<UnwrapResult>;
46
46
  createBTCTransfer(parameters: IFundingTransactionParameters): Promise<BitcoinTransferResponse>;
@@ -93,21 +93,23 @@ export class TransactionFactory {
93
93
  utxos: [refundUTXO],
94
94
  };
95
95
  }
96
- async wrap(warpParameters) {
97
- if (warpParameters.amount < currentConsensusConfig.VAULT_MINIMUM_AMOUNT) {
98
- throw new Error(`Amount is too low. Minimum consolidation is ${currentConsensusConfig.VAULT_MINIMUM_AMOUNT} sat. Received ${warpParameters.amount} sat. Make sure that you cover the unwrap consolidation fees of ${currentConsensusConfig.UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT}sat.`);
96
+ async wrap(wrapParameters) {
97
+ if (wrapParameters.amount < currentConsensusConfig.VAULT_MINIMUM_AMOUNT) {
98
+ throw new Error(`Amount is too low. Minimum consolidation is ${currentConsensusConfig.VAULT_MINIMUM_AMOUNT} sat. Received ${wrapParameters.amount} sat. Make sure that you cover the unwrap consolidation fees of ${currentConsensusConfig.UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT}sat.`);
99
99
  }
100
- const childTransactionRequiredValue = warpParameters.amount + currentConsensusConfig.UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT;
101
- const wbtc = new wBTC(warpParameters.network, warpParameters.chainId);
100
+ const childTransactionRequiredValue = wrapParameters.amount +
101
+ currentConsensusConfig.UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT +
102
+ (wrapParameters.priorityFee || 300n);
103
+ const wbtc = new wBTC(wrapParameters.network, wrapParameters.chainId);
102
104
  const to = wbtc.getAddress();
103
105
  const fundingParameters = {
104
- ...warpParameters,
106
+ ...wrapParameters,
105
107
  amount: childTransactionRequiredValue,
106
- to: warpParameters.to ?? to,
108
+ to: wrapParameters.to ?? to,
107
109
  };
108
110
  const preFundingTransaction = await this.createFundTransaction(fundingParameters);
109
- warpParameters.utxos = this.getUTXOAsTransaction(preFundingTransaction.tx, to, 0);
110
- const preTransaction = new WrapTransaction(warpParameters);
111
+ wrapParameters.utxos = this.getUTXOAsTransaction(preFundingTransaction.tx, to, 0);
112
+ const preTransaction = new WrapTransaction(wrapParameters);
111
113
  await preTransaction.signTransaction();
112
114
  const parameters = await preTransaction.getFundingTransactionParameters();
113
115
  parameters.amount += childTransactionRequiredValue;
@@ -117,7 +119,7 @@ export class TransactionFactory {
117
119
  throw new Error('Could not sign funding transaction.');
118
120
  }
119
121
  const newParams = {
120
- ...warpParameters,
122
+ ...wrapParameters,
121
123
  utxos: this.getUTXOAsTransaction(signedTransaction.tx, to, 0),
122
124
  randomBytes: preTransaction.getRndBytes(),
123
125
  nonWitnessUtxo: signedTransaction.tx.toBuffer(),
@@ -129,7 +131,7 @@ export class TransactionFactory {
129
131
  vaultAddress: finalTransaction.vault,
130
132
  amount: finalTransaction.amount,
131
133
  receiverAddress: finalTransaction.receiver,
132
- utxos: this.getUTXOAsTransaction(signedTransaction.tx, warpParameters.from, 1),
134
+ utxos: this.getUTXOAsTransaction(signedTransaction.tx, wrapParameters.from, 1),
133
135
  };
134
136
  }
135
137
  async unwrapSegwit(unwrapParameters) {
@@ -110,7 +110,7 @@ export class TransactionBuilder extends TweakedTransaction {
110
110
  if (this.regenerated) {
111
111
  throw new Error('Transaction was regenerated');
112
112
  }
113
- return this.transaction.extractTransaction(false);
113
+ return this.transaction.extractTransaction(true, true);
114
114
  }
115
115
  throw new Error('Could not sign transaction');
116
116
  }
@@ -292,7 +292,7 @@ export class TransactionBuilder extends TweakedTransaction {
292
292
  if (output.value < TransactionBuilder.MINIMUM_DUST) {
293
293
  this.feeOutput = null;
294
294
  if (output.value < 0) {
295
- throw new Error(`setFeeOutput: Insufficient funds to pay the fees. Fee: ${fee} > Value: ${initialValue}. Total input: ${this.totalInputAmount} sat`);
295
+ throw new Error(`setFeeOutput: Insufficient funds to pay the fees. Fee: ${fee} < Value: ${initialValue}. Total input: ${this.totalInputAmount} sat`);
296
296
  }
297
297
  }
298
298
  else {
@@ -13,7 +13,7 @@ export interface ITransactionParameters extends ITweakedTransactionData {
13
13
  estimatedFees?: bigint;
14
14
  chainId?: ChainId;
15
15
  readonly feeRate: number;
16
- readonly priorityFee?: bigint;
16
+ readonly priorityFee: bigint;
17
17
  }
18
18
  export interface IFundingTransactionParameters extends ITransactionParameters {
19
19
  amount: bigint;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "type": "module",
3
- "version": "1.0.91",
3
+ "version": "1.0.92",
4
4
  "author": "BlobMaster41",
5
5
  "description": "OPNet transaction library allows you to create and sign transactions for the OPNet network.",
6
6
  "engines": {
package/src/_version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '1.0.91';
1
+ export const version = '1.0.92';
@@ -207,32 +207,34 @@ export class TransactionFactory {
207
207
 
208
208
  /**
209
209
  * Basically it's fun to manage UTXOs.
210
- * @param {IWrapParameters} warpParameters - The wrap parameters
210
+ * @param {IWrapParameters} wrapParameters - The wrap parameters
211
211
  * @returns {Promise<WrapResult>} - The signed transaction
212
212
  * @throws {Error} - If the transaction could not be signed
213
213
  */
214
- public async wrap(warpParameters: Omit<IWrapParameters, 'calldata'>): Promise<WrapResult> {
215
- if (warpParameters.amount < currentConsensusConfig.VAULT_MINIMUM_AMOUNT) {
214
+ public async wrap(wrapParameters: Omit<IWrapParameters, 'calldata'>): Promise<WrapResult> {
215
+ if (wrapParameters.amount < currentConsensusConfig.VAULT_MINIMUM_AMOUNT) {
216
216
  throw new Error(
217
- `Amount is too low. Minimum consolidation is ${currentConsensusConfig.VAULT_MINIMUM_AMOUNT} sat. Received ${warpParameters.amount} sat. Make sure that you cover the unwrap consolidation fees of ${currentConsensusConfig.UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT}sat.`,
217
+ `Amount is too low. Minimum consolidation is ${currentConsensusConfig.VAULT_MINIMUM_AMOUNT} sat. Received ${wrapParameters.amount} sat. Make sure that you cover the unwrap consolidation fees of ${currentConsensusConfig.UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT}sat.`,
218
218
  );
219
219
  }
220
220
 
221
221
  const childTransactionRequiredValue: bigint =
222
- warpParameters.amount + currentConsensusConfig.UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT;
222
+ wrapParameters.amount +
223
+ currentConsensusConfig.UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT +
224
+ (wrapParameters.priorityFee || 300n);
223
225
 
224
- const wbtc: wBTC = new wBTC(warpParameters.network, warpParameters.chainId);
226
+ const wbtc: wBTC = new wBTC(wrapParameters.network, wrapParameters.chainId);
225
227
  const to = wbtc.getAddress();
226
228
  const fundingParameters: IFundingTransactionParameters = {
227
- ...warpParameters,
229
+ ...wrapParameters,
228
230
  amount: childTransactionRequiredValue,
229
- to: warpParameters.to ?? to,
231
+ to: wrapParameters.to ?? to,
230
232
  };
231
233
 
232
234
  const preFundingTransaction = await this.createFundTransaction(fundingParameters);
233
- warpParameters.utxos = this.getUTXOAsTransaction(preFundingTransaction.tx, to, 0);
235
+ wrapParameters.utxos = this.getUTXOAsTransaction(preFundingTransaction.tx, to, 0);
234
236
 
235
- const preTransaction: WrapTransaction = new WrapTransaction(warpParameters);
237
+ const preTransaction: WrapTransaction = new WrapTransaction(wrapParameters);
236
238
 
237
239
  // Initial generation
238
240
  await preTransaction.signTransaction();
@@ -250,7 +252,7 @@ export class TransactionFactory {
250
252
  }
251
253
 
252
254
  const newParams: IWrapParameters = {
253
- ...warpParameters,
255
+ ...wrapParameters,
254
256
  utxos: this.getUTXOAsTransaction(signedTransaction.tx, to, 0), // always 0
255
257
  randomBytes: preTransaction.getRndBytes(),
256
258
  nonWitnessUtxo: signedTransaction.tx.toBuffer(),
@@ -265,7 +267,7 @@ export class TransactionFactory {
265
267
  vaultAddress: finalTransaction.vault,
266
268
  amount: finalTransaction.amount,
267
269
  receiverAddress: finalTransaction.receiver,
268
- utxos: this.getUTXOAsTransaction(signedTransaction.tx, warpParameters.from, 1),
270
+ utxos: this.getUTXOAsTransaction(signedTransaction.tx, wrapParameters.from, 1),
269
271
  };
270
272
  }
271
273
 
@@ -243,7 +243,7 @@ export abstract class TransactionBuilder<T extends TransactionType> extends Twea
243
243
  throw new Error('Transaction was regenerated');
244
244
  }
245
245
 
246
- return this.transaction.extractTransaction(false);
246
+ return this.transaction.extractTransaction(true, true);
247
247
  }
248
248
 
249
249
  throw new Error('Could not sign transaction');
@@ -607,7 +607,7 @@ export abstract class TransactionBuilder<T extends TransactionType> extends Twea
607
607
 
608
608
  if (output.value < 0) {
609
609
  throw new Error(
610
- `setFeeOutput: Insufficient funds to pay the fees. Fee: ${fee} > Value: ${initialValue}. Total input: ${this.totalInputAmount} sat`,
610
+ `setFeeOutput: Insufficient funds to pay the fees. Fee: ${fee} < Value: ${initialValue}. Total input: ${this.totalInputAmount} sat`,
611
611
  );
612
612
  }
613
613
  } else {
@@ -16,7 +16,7 @@ export interface ITransactionParameters extends ITweakedTransactionData {
16
16
  chainId?: ChainId;
17
17
 
18
18
  readonly feeRate: number;
19
- readonly priorityFee?: bigint;
19
+ readonly priorityFee: bigint;
20
20
  }
21
21
 
22
22
  export interface IFundingTransactionParameters extends ITransactionParameters {