utxostack/rgbpp-sdk

Add a new optional parameter `transactionConfirmed` to the `sendBtc` method

Flouse opened this issue · 0 comments

An app requests a feature in the sendBtc method of @rgbpp-sdk/btc, to prevent consecutive transactions.

Add a new optional parameter transactionConfirmed to the sendBtc method

The purpose of this parameter is to prevent consecutive transactions from being sent before the previous one is confirmed.

Description

Proposed Changes

  1. Set the default value of transactionConfirmed to false.
  2. Implement logic to check the value of transactionConfirmed:
  3. If the previous transaction has not been confirmed and transactionConfirmed is true, throw an appropriate error.

Example Usage

const psbt = await sendBtc({
  from: address,
  tos: [
    {
      address: TARGET_ADDRESS,
      value: 546,
    },
  ],
  transactionConfirmed: true, // If the previous transaction is not confirmed, an error will be thrown
  fromPubkey: pubkey,
  changeAddress: address,
  feeRate: 1,
  source,
});

Benefits

Provides more control and flexibility for developers