-
Notifications
You must be signed in to change notification settings - Fork 25
feat: add advanced rbf guide #237
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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.
Show resolved
Hide 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 | ||
| ``` | ||
Uh oh!
There was an error while loading. Please reload this page.