@btc-vision/transaction 1.8.3 → 1.8.5

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@btc-vision/transaction",
3
3
  "type": "module",
4
- "version": "1.8.3",
4
+ "version": "1.8.5",
5
5
  "author": "BlobMaster41",
6
6
  "description": "OPNet transaction library allows you to create and sign transactions for the OPNet network.",
7
7
  "engines": {
package/src/_version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '1.8.3';
1
+ export const version = '1.8.5';
@@ -182,7 +182,7 @@ export abstract class Generator {
182
182
  writer.writeBytes(feature.data.solution);
183
183
 
184
184
  if (feature.data.graffiti) {
185
- writer.writeBytes(feature.data.graffiti);
185
+ writer.writeBytesWithLength(feature.data.graffiti);
186
186
  }
187
187
 
188
188
  finalBuffer.writeBytesWithLength(writer.getBuffer());
@@ -274,7 +274,10 @@ export class TransactionFactory {
274
274
  0n,
275
275
  );
276
276
 
277
- return total > optionalInputValue ? total - optionalInputValue : 0n;
277
+ const adjusted = total > optionalInputValue ? total - optionalInputValue : 0n;
278
+ return adjusted < TransactionBuilder.MINIMUM_DUST
279
+ ? TransactionBuilder.MINIMUM_DUST
280
+ : adjusted;
278
281
  }
279
282
 
280
283
  return total;
@@ -975,6 +978,10 @@ export class TransactionFactory {
975
978
  throw new Error(`Failed to converge on ${debugPrefix} funding amount`);
976
979
  }
977
980
 
981
+ if (estimatedFundingAmount === 0n) {
982
+ throw new Error(`Impossible. Transaction cant be free.`);
983
+ }
984
+
978
985
  return {
979
986
  finalTransaction: finalPreTransaction,
980
987
  estimatedAmount: estimatedFundingAmount,