utxostack / rgbpp-sdk

Utilities for Bitcoin and RGB++ asset integration
ISC License
53 stars 18 forks source link

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

Closed Flouse closed 7 months ago

Flouse commented 7 months ago

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