-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(btc): support full RBF #150
Conversation
This draft PR doesn't look ready yet |
Yes, the PR is still in draft, and it's currently for API interface preview only. |
18dbb20
to
72b8e30
Compare
Please help review 'full RBF' test analysis. |
The PR is now ready for review/test, please update your status here @Dawn-githup, thanks. |
590f0c8
to
e6a87e0
Compare
todo listNormal scenario:
Abnormal scenario:
Boundary value scenario:
|
If we have an unconfirmed transaction chain:
And if we wish to construct an RBF transaction of the TX_A, let's call it TX_AR. When constructing the TX_AR, we should exclude O2 and O3 from being included in the inputs, preventing circular reference error since our goal is to replace TX_A and deduct its children (TX_B) from the blockchain. Kinda like the grandfather paradox. Here's the question: how do we know that O3 should be excluded? To address it, we may need to use this kind of API to help identify which transaction should be excluded in the RBF: https://mempool.space/docs/api/rest#get-transaction-outspends The basic logic:
What's more, things can get much more complicated if we're constructing an RBF of an RBF of a transaction. Another solution is to expose the On second thought, maybe just set |
What about adding these descriptions to the README or code comments? |
Same recommendation as above |
I was thinking of maybe creating Markdown docs for each API, like this: |
b8a99b6
to
08200c9
Compare
Conflicts have been resolved, and the history commits are squashed into 8ce3593. Additionally, all changes are documented in the changeset: https://github.com/ckb-cell/rgbpp-sdk/blob/08200c974ef336661723cc7556a003932babda9a/.changeset/spicy-cups-cheat.md |
Changes
sendRbf()
andcreateSendRbfBuilder()
APIs to support Full-RBF of BTC transactionsexcludeUtxos
,skipInputsValidation
options in thesendUtxos()
API to support the RBF featureonlyProvableUtxos
option in thesendRgbppUtxos()
API for future update supportschangeIndex
in the return type of the BTC Builder APIsRelated issues
Reference
New APIs
The
sendRbf()
andcreateSendRbfBuilder()
APIs are design for constructing BTC Full-RBF transactions.txHex
The hex of the original transaction.
changeIndex
By default, all the inputs and outputs from the original transaction remains the same in the RBF transaction, but if you wish to charge fee from or return change satoshi to the change output of the original transaction, you can specify the option.
requireValidOutputsValue
Require the value of each output in the RBF transaction to be greater or equals to
minUtxoSatoshi
.requireGreaterFeeAndRate
Require the fee rate and the fee amount of the RBF transaction to be greater than the original transaction.
inputsPubkey
A Map of addresses and public keys. It's useful when the original transaction contains multi-origin P2TR inputs. This option is currently unstable and can be updated, also note that in you won't need it most cases.
New options
skipInputsValidation
Previously, when the
onlyConfirmedUtxos
istrue
, all inputs will be validated and an error will be thrown if any input is unconfirmed. With theskipInputsValidation
option, you can skip validation of theprops.inputs
, while still apply theonlyConfirmedUtxos
rule to the satoshi collector.Which means if
onlyConfirmedUtxos = true
andskipInputsValidation = true
:props.inputs
option can be unconfirmed UTXOsIn the
sendRbf()
API, this option is always set totrue
, allowing transaction chains to be RBF.excludeUtxos
This option is a list of UTXO[] to be excluded from the satoshi collection process when paying fee.
In the
sendRbf()
API, this option is used to exclude the outputs from the original transaction, preventing errors related to circular references (the RBF may uses outputs of the original transaction as the inputs if they're not excluded).onlyProvableUtxos
In the
sendRgbppUtxos()
API, this option is set totrue
by default, and it checks if each input's address is the same as thefrom
address. If set tofalse
, the address of the inputs can be different from thefrom
address.New return type
changeIndex
All BTC Builder APIs now return a new property
changeIndex
, which indicates the specific output in the generated transaction to be the change output. Note that the value of thechangeIndex
can be-1
, meaning the transaction has no change output.