Skip to content
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

Wallet: add BIP125 RBF bump fee #1170

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
0a3ecf2
mempool: Allow double spend of RBF transaction
pinheadmz Jul 3, 2019
bb8b4b0
mempool: Reject RBF replacements with insufficient fees
pinheadmz Jul 5, 2019
d62f1b3
mempool: Reject RBF replacement edge cases
pinheadmz Jul 5, 2019
70ef286
mempool: replace by fee
pinheadmz Jul 5, 2019
f3cd659
mempool: clarify eviction of RBF conflicts
pinheadmz Oct 14, 2019
bf43d9a
mempool: improve readability and documentation of RBF logic
pinheadmz Aug 11, 2023
caabf10
mempool: allow replacement of tx spending unconfirmed utxo
pinheadmz Aug 19, 2023
5e0cd19
mempool: restore original isDoubleSpend() implementation
pinheadmz Aug 19, 2023
6f04c0d
mempool: fix RBF Rule #2
pinheadmz Aug 19, 2023
6ae1752
mempool: check input index when comparing replacement to conflict
pinheadmz Aug 21, 2023
24408b9
mempool: allow replacement of tx spending unconfirmed utxo
pinheadmz Aug 11, 2023
f316989
mempool: allow RBF by default
pinheadmz Aug 1, 2023
f83e39d
wallet: make all txs replaceable by default, optionally opt out
pinheadmz Aug 1, 2023
f99a7c2
test: add utility forEvent()
pinheadmz Aug 1, 2023
b8afe61
wallet: implement and test bumpTXFee()
pinheadmz Aug 3, 2023
e83563a
cli/http: add bwallet-cli bump <txid> <rate> <sign> <passphrase>
pinheadmz Aug 11, 2023
9a1135a
wallet: do not replace TX with more than one change address
pinheadmz Sep 21, 2023
d5d302c
wallet: do not accept too-low RBF replacement fee rate
pinheadmz Sep 21, 2023
4d97480
wallet rbf: add new in/out if necessary
pinheadmz Sep 21, 2023
5f472ad
wallet rbf: do not violate rule 6
pinheadmz Sep 22, 2023
14e5743
wallet rbf: add new in/out when change output is too low for RBF fee
pinheadmz Sep 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions bin/bwallet-cli
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ class CLI {
passphrase: this.config.str('passphrase'),
outputs: outputs,
smart: this.config.bool('smart'),
replaceable: this.config.bool('replaceable'),
rate: this.config.ufixed('rate', 8),
subtractFee: this.config.bool('subtract-fee')
};
Expand Down Expand Up @@ -327,6 +328,7 @@ class CLI {
passphrase: this.config.str('passphrase'),
outputs: [output],
smart: this.config.bool('smart'),
replaceable: this.config.bool('replaceable'),
rate: this.config.ufixed('rate', 8),
subtractFee: this.config.bool('subtract-fee'),
sign: this.config.bool('sign')
Expand Down Expand Up @@ -362,6 +364,17 @@ class CLI {
this.log('Abandoned tx: ' + hash);
}

async bumpTX() {
const hash = this.config.str([0, 'hash']);
const rate = this.config.uint([1, 'rate']);
const sign = this.config.bool([2, 'sign']);
const passphrase = this.config.str([3, 'passphrase']);

const tx = await this.wallet.bumpTX(hash, rate, sign, passphrase);

this.log(tx);
}

async getDetails() {
const hash = this.config.str(0);
const details = await this.wallet.getTX(hash);
Expand Down Expand Up @@ -603,6 +616,9 @@ class CLI {
case 'rescan':
await this.rescan();
break;
case 'bump':
await this.bumpTX();
break;
default:
this.log('Unrecognized command.');
this.log('Commands:');
Expand All @@ -615,6 +631,7 @@ class CLI {
this.log(' $ balance: Get wallet balance.');
this.log(' $ block [height]: View wallet block.');
this.log(' $ blocks: List wallet blocks.');
this.log(' $ bump [hash]: Bump TX fee with replacement.');
this.log(' $ change: Derive new change address.');
this.log(' $ coins: View wallet coins.');
this.log(' $ dump [address]: Get wallet key WIF by address.');
Expand Down
28 changes: 28 additions & 0 deletions lib/client/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,21 @@
return this.del(`/wallet/${id}/tx/${hash}`);
}

/**
* @param {Number} id
* @param {Hash} hash
* @param {Number?} rate
* @param {Bool?} sign
* @param {String?} passphrase
* @returns {Promise}
*/

bumpTX(id, hash, rate, sign, passphrase) {
return this.post(

Check warning on line 369 in lib/client/wallet.js

View check run for this annotation

Codecov / codecov/patch

lib/client/wallet.js#L369

Added line #L369 was not covered by tests
`/wallet/${id}/bump/${hash}`,
{hash, rate, sign, passphrase});
}

/**
* Create a transaction, fill.
* @param {Number} id
Expand Down Expand Up @@ -832,6 +847,19 @@
return this.client.abandon(this.id, hash);
}

/**
* Send an RBF replacement to bump fee
* @param {Hash} hash
* @param {Number?} rate
* @param {Bool?} sign
* @param {String?} passphrase
* @returns {Promise}
*/

bumpTX(hash, rate, sign, passphrase) {
return this.client.bumpTX(this.id, hash);

Check warning on line 860 in lib/client/wallet.js

View check run for this annotation

Codecov / codecov/patch

lib/client/wallet.js#L860

Added line #L860 was not covered by tests
}

/**
* Create a transaction, fill.
* @param {Object} options
Expand Down
Loading