Skip to content

Commit

Permalink
fix(inscriber): ensure output is higher than dust (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nanosync authored Dec 6, 2023
1 parent 5ed08de commit afdcd20
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions packages/sdk/src/transactions/Inscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
OnOffUnion
} from ".."
import { Network } from "../config/types"
import { MINIMUM_AMOUNT_IN_SATS } from "../constants"
import { NestedObject } from "../utils/types"
import { PSBTBuilder } from "./PSBTBuilder"
import { SkipStrictSatsCheckOptions, UTXOLimited } from "./types"
Expand Down Expand Up @@ -269,8 +270,19 @@ export class Inscriber extends PSBTBuilder {
: skipStrictSatsCheck && customAmount && !isNaN(customAmount)
? customAmount
: this.outputAmount + this.fee
const [utxo] = await this.retrieveSelectedUTXOs(this.commitAddress!, amount)
this.suitableUnspent = utxo

// Output to be paid to user
if (amount < MINIMUM_AMOUNT_IN_SATS) {
throw new Error("Requested output amount is lower than minimum dust amount")
}

const utxos = await this.retrieveSelectedUTXOs(this.commitAddress!, amount)

if (utxos.length === 0) {
throw new Error("No selected utxos retrieved")
}

this.suitableUnspent = utxos[0]
this.ready = true

return this.suitableUnspent
Expand Down

0 comments on commit afdcd20

Please sign in to comment.