From 1afa18f83a5b9454be5e7647bd24e3ac46dadf89 Mon Sep 17 00:00:00 2001 From: Nishant Ghodke <64554492+iamcrazycoder@users.noreply.github.com> Date: Thu, 28 Sep 2023 13:11:13 +0530 Subject: [PATCH] fix(sdk): create outputs for minimum amount in utxo splitter (#72) * fix: create outputs for minimum amount in utxo splitter * feat: add split-utxo npm command to run example * fix: fetch all inscriptions to find by outpoint --- examples/node/package.json | 3 ++- packages/sdk/src/instant-trade/InstantTradeBuilder.ts | 3 ++- packages/sdk/src/utxos/UTXOManager.ts | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/node/package.json b/examples/node/package.json index f33f44b6..20dd0919 100644 --- a/examples/node/package.json +++ b/examples/node/package.json @@ -11,7 +11,8 @@ "create-psbt": "node create-psbt", "instant-buy": "node instant-buy", "publish-collection": "node collections", - "build-psbt": "node build-psbt" + "build-psbt": "node build-psbt", + "split-utxo": "node split-utxo" }, "author": "", "license": "ISC", diff --git a/packages/sdk/src/instant-trade/InstantTradeBuilder.ts b/packages/sdk/src/instant-trade/InstantTradeBuilder.ts index b1c458a0..8ed49dbe 100644 --- a/packages/sdk/src/instant-trade/InstantTradeBuilder.ts +++ b/packages/sdk/src/instant-trade/InstantTradeBuilder.ts @@ -66,7 +66,8 @@ export default class InstantTradeBuilder extends PSBTBuilder { throw new Error("set inscription outpoint to the class") } - this.inscription = await this.datasource.getInscription(this.inscriptionOutpoint) + const inscriptions = await this.datasource.getInscriptions({ outpoint: this.inscriptionOutpoint }) + this.inscription = inscriptions.find((inscription) => inscription.outpoint === this.inscriptionOutpoint) if (!this.inscription) { throw new Error("Inscription not found") } diff --git a/packages/sdk/src/utxos/UTXOManager.ts b/packages/sdk/src/utxos/UTXOManager.ts index c5745c27..9257c559 100644 --- a/packages/sdk/src/utxos/UTXOManager.ts +++ b/packages/sdk/src/utxos/UTXOManager.ts @@ -44,7 +44,7 @@ export default class UTXOManager extends PSBTBuilder { this.outputs.push({ address: destinationAddress || this.address, - value: amount + value: MINIMUM_AMOUNT_IN_SATS }) }