Add a new optional parameter `transactionConfirmed` to the `sendBtc` method
Flouse opened this issue · 0 comments
Flouse commented
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
- Set the default value of
transactionConfirmed
tofalse
. - Implement logic to check the value of
transactionConfirmed
:- If
transactionConfirmed
istrue
, proceed with the transaction only if the previous transactions of the inputs has been confirmed.
More specifically, theinput.UTXO.status.confirmed
should be true in this case:
https://github.com/ckb-cell/rgbpp-sdk/blob/1458e40291b97ebfbbfc2007df83a24043e593a5/packages/service/src/types/btc.ts#L65-L75 - If
transactionConfirmed
isfalse
, proceed with the transaction regardless of the status of the previous transaction.
- If
- If the previous transaction has not been confirmed and
transactionConfirmed
istrue
, 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