From feeb52dbf73bb804de2b89ae066f4154503452ca Mon Sep 17 00:00:00 2001 From: Sai Kranthi Date: Fri, 14 Jul 2023 10:15:35 +0530 Subject: [PATCH] feat(sdk): enable RBF --- packages/sdk/src/inscription/collection.ts | 2 +- packages/sdk/src/inscription/instant-buy.ts | 12 ++++++++---- packages/sdk/src/transactions/OrdTransaction.ts | 1 + 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/sdk/src/inscription/collection.ts b/packages/sdk/src/inscription/collection.ts index 20abf187..45529c13 100644 --- a/packages/sdk/src/inscription/collection.ts +++ b/packages/sdk/src/inscription/collection.ts @@ -151,7 +151,7 @@ export type PublishCollectionOptions = { export type CollectionInscription = { iid: string; lim: number; - sri: string; + sri?: string; }; export type MintFromCollectionOptions = { diff --git a/packages/sdk/src/inscription/instant-buy.ts b/packages/sdk/src/inscription/instant-buy.ts index 219bfa64..7890fece 100644 --- a/packages/sdk/src/inscription/instant-buy.ts +++ b/packages/sdk/src/inscription/instant-buy.ts @@ -175,7 +175,8 @@ export async function generateBuyerPsbt({ const input: any = { hash: dummyUtxo.txid, index: dummyUtxo.n, - nonWitnessUtxo: rawTx.toBuffer() + nonWitnessUtxo: rawTx.toBuffer(), + sequence: 0xfffffffd // Needs to be at least 2 below max int value to be RBF }; const p2shInputRedeemScript: any = {}; @@ -262,7 +263,8 @@ export async function generateBuyerPsbt({ const input: any = { hash: utxo.txid, index: utxo.n, - nonWitnessUtxo: rawTx.toBuffer() + nonWitnessUtxo: rawTx.toBuffer(), + sequence: 0xfffffffd // Needs to be at least 2 below max int value to be RBF }; if (pubKeyType === "taproot") { @@ -372,7 +374,8 @@ export async function generateDummyUtxos({ const input: any = { hash: utxo.txid, index: utxo.n, - nonWitnessUtxo: rawTx.toBuffer() + nonWitnessUtxo: rawTx.toBuffer(), + sequence: 0xfffffffd, // Needs to be at least 2 below max int value to be RBF }; if (pubKeyType === "taproot") { @@ -525,7 +528,8 @@ export async function getSellerInputsOutputs({ const data: any = { hash: ordUtxo.txid, index: parseInt(ordUtxo.n), - nonWitnessUtxo: rawTx.toBuffer() + nonWitnessUtxo: rawTx.toBuffer(), + sequence: 0xfffffffd // Needs to be at least 2 below max int value to be RBF }; const postage = ordUtxo.sats; diff --git a/packages/sdk/src/transactions/OrdTransaction.ts b/packages/sdk/src/transactions/OrdTransaction.ts index b3b8e30a..ea7ed4bf 100644 --- a/packages/sdk/src/transactions/OrdTransaction.ts +++ b/packages/sdk/src/transactions/OrdTransaction.ts @@ -90,6 +90,7 @@ export class OrdTransaction { try { psbt.addInput({ + sequence: 0xfffffffd, // Needs to be at least 2 below max int value to be RBF hash: this.#suitableUnspent.txid, index: parseInt(this.#suitableUnspent.n), tapInternalKey: Buffer.from(this.#xKey, "hex"),