Skip to content

Commit

Permalink
fix(inscriber): accept and pass down datasource in inscriber (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevzzsk authored Mar 15, 2024
1 parent 1bd6860 commit da382af
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions packages/sdk/src/transactions/Inscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as bitcoin from "bitcoinjs-lib"
import { Tapleaf } from "bitcoinjs-lib/src/types"

import {
BaseDatasource,
buildWitnessScript,
createTransaction,
encodeObject,
Expand Down Expand Up @@ -56,7 +57,8 @@ export class Inscriber extends PSBTBuilder {
outputs = [],
encodeMetadata = false,
safeMode,
meta
meta,
datasource
}: InscriberArgOptions) {
super({
address,
Expand All @@ -65,7 +67,8 @@ export class Inscriber extends PSBTBuilder {
network,
publicKey,
outputs,
autoAdjustment: false
autoAdjustment: false,
datasource
})
if (!publicKey || !changeAddress || !mediaContent) {
throw new OrditSDKError("Invalid options provided")
Expand Down Expand Up @@ -133,10 +136,12 @@ export class Inscriber extends PSBTBuilder {
if (this.recovery) {
this.recoverAmount = this.suitableUnspent.sats - this.fee
// when in recovery mode, there will only be 1 output
this.outputs = [{
address: this.changeAddress || this.address,
value: this.recoverAmount
}]
this.outputs = [
{
address: this.changeAddress || this.address,
value: this.recoverAmount
}
]
}

await this.prepare() // prepare PSBT using PSBTBuilder
Expand Down Expand Up @@ -278,8 +283,8 @@ export class Inscriber extends PSBTBuilder {
const amount = this.recovery
? this.outputAmount - this.fee
: skipStrictSatsCheck && customAmount && !isNaN(customAmount)
? customAmount
: this.outputAmount + this.fee
? customAmount
: this.outputAmount + this.fee

// Output to be paid to user
if (amount < MINIMUM_AMOUNT_IN_SATS) {
Expand Down Expand Up @@ -312,6 +317,7 @@ export type InscriberArgOptions = Pick<GetWalletOptions, "safeMode"> & {
meta?: NestedObject
outputs?: Outputs
encodeMetadata?: boolean
datasource?: BaseDatasource
}

type Outputs = Array<{ address: string; value: number }>

0 comments on commit da382af

Please sign in to comment.