Skip to content

feat(sdk): add PreInscriberWithProtection - #1

Open
kevzzsk wants to merge 2 commits into
kevin/pre-inscribe-utxo-managerfrom
kevin/pre-inscribe-protection
Open

feat(sdk): add PreInscriberWithProtection#1
kevzzsk wants to merge 2 commits into
kevin/pre-inscribe-utxo-managerfrom
kevin/pre-inscribe-protection

Conversation

@kevzzsk

@kevzzsk kevzzsk commented Jan 9, 2025

Copy link
Copy Markdown
Owner

What this PR does / why we need it:

requires:

Introduce PreInscriberWithProtection class that is used to create series of CPFP transaction that allow for safe ordinals transaction.

Seller create inscription PSBT and signs the PSBT with SIGHASH_ALL | SIGHASH_ANYONECANPAY.

await PreInscriberWithProtection.createInscriptionPSBT({
        inscriptionId: id,
        sellerPublicKey: sellerWallet.publicKey,
        sellerAddress: sellerWallet.selectedAddress,
        receivePaymentAddress: sellerWallet.selectedAddress,
        inscriptionPrice: 1000,
        escrowPublicKey: escrowWallet.publicKey,
        datasource,
        network,
        chain
      })

Buyer will then use that Seller signed InscriptionPSBT to craft series of transactions.

const preinscriber = new PreInscriberWithProtection({
    network,
    chain,
    datasource,
    inscriptionPsbts: signedInscriptionPsbts, // pass in the seller signed psbts
    escrowPublicKey: escrowWallet.publicKey,
    buyerAddress: buyerWallet.selectedAddress,
    buyerPublicKey: buyerWallet.publicKey,
    receiveAddress: buyerWalletTaprootAddress,
    effectiveFeeRate: 8
  })
  // build the transactions
  const psbts = await preinscriber.buildTransactions({ uniqueId: "uniqueId" })

Then buyer + escrow wallet will sign for the PSBTs and relay all transactions.

for a full example look at examples/node/pre-inscribe-protection.js

Which issue(s) does this PR fixes?:

Additional comments?:

Developer Checklist:

  • Read your code changes at least once
  • No console errors
  • Unit tests*
  • Added e2e tests*

@kevzzsk kevzzsk self-assigned this Jan 9, 2025
@kevzzsk
kevzzsk force-pushed the kevin/pre-inscribe-protection branch from a374fea to 56c1c88 Compare January 9, 2025 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant