This repository was archived by the owner on Jul 27, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
feat: add advanced rbf guide #237
Open
gregdhill
wants to merge
2
commits into
interlay:master
Choose a base branch
from
gregdhill:feat/replace-by-fee
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -320,3 +320,55 @@ If your Vault clients holds at least _some BTC in custody_, you have two options | |
|
|
||
| - **Replace**: leaving through _replace_, requires you to request being replaced by another Vault. You can request to be replaced through the Vault dashboard by replace 100% of the BTC that is locked with the Vault and waiting for other Vaults to accept the request. Once the replace request is accepted, your Vault client will execute the replace request by sending BTC to the accepting Vault and executing the request on the parachain. | ||
| - **Redeem**, leaving through _redeem_ requires you to wait for a user or yourself to redeem the entire amount of BTC that the Vault has in custody. Only after you have 0 BTC, can the Vault client withdraw its entire collateral. If you redeem with your own Vault, the Vault will not receive fees for this such that 0 BTC remains in your Vault client. | ||
|
|
||
| ## Replace-By-Fee | ||
|
|
||
| When the Bitcoin mempool is significantly congested it may take some time for redeem payments to be included on mainnet. In the worst case this could lead to a theft report on the parachain if the request period has elapsed. For this reason, all transactions made by the Vault should be "bip125-replaceable" to allow Vault operators to set a higher fee. | ||
|
|
||
| !> The following instructions are for advanced users only, in most cases the Vault client should automatically bump the fee if required. Manually bumping the fees may cause the wallet to not contain sufficient Bitcoin to fulfil future redeem requests. It may also be a possibility to consider third-party transaction acceleration services. | ||
|
|
||
| Note the `$TXID` which is the transaction identifier of that which will be replaced. | ||
|
|
||
| ### Simple | ||
|
|
||
| The easiest way to bump the transaction fees is by using the `bumpfee` command. | ||
|
|
||
| ```shell | ||
| bitcoin-cli bumpfee $TXID | ||
| ``` | ||
|
|
||
| This is not recommended however since it may insert an additional (unregistered) change address. | ||
|
|
||
| ### Advanced | ||
|
|
||
| This approach is slightly more involved but the following commands will reduce some overhead. | ||
|
|
||
| You will need to set `-rpcwallet` when using `bitcoin-cli`. For example if the transaction was made by your `KSM-KBTC` wallet this should be `$KEYNAME-KSM-KBTC` where `$KEYNAME` is the `AccountId` your Vault would point to. | ||
|
|
||
| Before continuing you will need to set the `$CHANGE_ADDRESS` to an address already registered by your Vault. List those addresses and set the `CHANGE_ADDRESS` variable. | ||
|
|
||
| ```shell | ||
| bitcoin-cli listunspent | ||
| ... | ||
|
|
||
| CHANGE_ADDRESS="<INSERT_HERE>" | ||
|
gregdhill marked this conversation as resolved.
|
||
| ``` | ||
|
|
||
| Review the optimal `feeRate` in BTC/kvB and set `$FEE_RATE` (for example `0.0001`). | ||
|
|
||
| ?> This was only tested on `regtest` so caution is to be advised for `mainnet` usage. | ||
|
|
||
| ```shell | ||
| # get the previous inputs | ||
| rawinputs=$(bitcoin-cli decoderawtransaction $(bitcoin-cli getrawtransaction $TXID) | jq '.vin[] | {txid, vout, sequence}' | jq -cs) | ||
| # get the previous outputs | ||
| rawoutputs=$(bitcoin-cli decoderawtransaction $(bitcoin-cli getrawtransaction $TXID) | jq '.vout[] | {value, address: .scriptPubKey.address} | ({(.address): .value})' | jq -cs) | ||
| # use those to create a new transaction | ||
| rawtx=$(bitcoin-cli createrawtransaction $rawinputs $rawoutputs) | ||
| # fund that tx with a better fee rate | ||
| fundedtx=$(bitcoin-cli fundrawtransaction $rawtx "{\"changeAddress\": \"$CHANGE_ADDRESS\", \"feeRate\": $FEE_RATE}" | jq -r .hex) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are counting on all addresses in the wallet to have been registered to the parachain, which is most cases will be true, but it's still a risky assumption. If e.g. a non-empty wallet was used when first starting the vault this would not hold (we do tell vaults not to do this.. but still)
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Theft reporting was removed here, addresses are no longer required to be registered. |
||
| # sign that with your wallet | ||
| signedtx=$(bitcoin-cli signrawtransactionwithwallet $fundedtx | jq -r .hex) | ||
| # finally broadcast the replaced tx | ||
| bitcoin-cli sendrawtransaction $signedtx | ||
| ``` | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.