Skip to content

Commit

Permalink
feat(sdk): add flag to skip strict sats check (#65)
Browse files Browse the repository at this point in the history
feat: add flag to skip strict sats check
  • Loading branch information
iamcrazycoder authored Sep 21, 2023
1 parent 44728e8 commit f0608e1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/sdk/src/transactions/OrdTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,14 @@ export class OrdTransaction {
this.#recovery = true
}

async isReady() {
async isReady(skipStrictSatsCheck = false) {
if (!this.#commitAddress || !this.#feeForWitnessData) {
throw new Error("No commit address found. Please generate a commit address.")
}

if (!this.ready) {
try {
await this.fetchAndSelectSuitableUnspent()
await this.fetchAndSelectSuitableUnspent(skipStrictSatsCheck)
} catch (error) {
return false
}
Expand All @@ -314,7 +314,7 @@ export class OrdTransaction {
return this.ready
}

async fetchAndSelectSuitableUnspent() {
async fetchAndSelectSuitableUnspent(skipStrictSatsCheck = false) {
if (!this.#commitAddress || !this.#feeForWitnessData) {
throw new Error("No commit address found. Please generate a commit address.")
}
Expand All @@ -329,7 +329,7 @@ export class OrdTransaction {
type: this.#safeMode === "on" ? "spendable" : "all"
})

const suitableUTXO = utxos.find((utxo) => utxo.sats >= amount)
const suitableUTXO = utxos.find((utxo) => skipStrictSatsCheck || (!skipStrictSatsCheck && utxo.sats >= amount))
if (!suitableUTXO) {
throw new Error("No suitable unspent found for reveal.")
}
Expand Down

0 comments on commit f0608e1

Please sign in to comment.