mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 09:35:38 +00:00
Wallet: Don't backdate locktime rbf #36040
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!36040
Loading…
Reference in a new issue
No description provided.
Delete branch "2026-dont-backdate-locktime-RBF"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes https://github.com/bitcoin/bitcoin/issues/26526
Currently, in Bitcoin Core, given an original transaction A and its replacement B, we refer to backdating when the locktime of A is higher than the locktime of B (
A.locktime > B.locktime). This can happen because Bitcoin Core enables anti-fee-sniping by default, which sets the transaction's locktime to the current block height. For privacy, 10% of the time, it instead sets a different locktime, randomly chosen between the current height and the current height minus 100 blocks. This can lead into having a replacement of a transaction with a locktime older than its original transaction. This is unrealistics and can be used as a wallet fingerprint.You can find a functional test to reproduce the behaviour mentioned here
The approach proposed in this PR adds a new parameter to
CoinControlto keep track of the previous locktime in the case of abumpfee. We then pass this parameter to the DiscourageFeeSniping function through a new parameter,minimum_height, whose default value is set to 0.Alternative approach:
Since the locktime of the new transaction is 0, we also considered setting it to the previous locktime value and then, inside `DiscourageFeeSniping`, saving the previous locktime and setting the transaction's locktime to the block height before applying any of the backdating logic. This way, we could avoid passing a new parameter to the function. We ultimately decided not to go with this approach, as it makes the code more difficult to follow.The only RPC that is affected by this changes is
bumpfee.The pr also includes a functional test in
wallet_bumpfee.pyto test that when replacing a transation usingbumpfeethe locktime is not backdated.We also conducted a small analysis to see how many the backdating in RBF transactions actually happen.
We have data on the replaced transactions from 2025-05-01 to 2026-06-01. With that we have been able to detect this many backdatings:We took the date of the last transaction of the
replacement chain (A replacement chain are all the transactions that replace themselves)
In total we have over 1,000,000 rbf transactions, but we see that on average there are only about 200-300 hundred replaccements backdating per week. Looking at the percentages we see that on average is less than 2% of all the transactions that have been replaced.
So, it is clear that backdating in replacement transactions is unusual. However, the few transactions that do exhibit backdating are easily fingerprintable as having been replaced using
bumpfeein Bitcoin Core or Electrum.The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste
<!--meta-tag:bot-skip-->into the comment that the bot should ignore.Conflicts
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
LLM Linter (✨ experimental)
Possible places where comparison-specific test macros should replace generic comparisons:
test/functional/wallet_bumpfee.py:assert locktime - 99 <= rebumped_locktime <= locktime→ Useassert_greater_than_or_equal(rebumped_locktime, locktime - 99)andassert_greater_than_or_equal(locktime, rebumped_locktime).2026-11-04 09:34:04
Concept ACK
b7935c708edc225e20dcab0820dff774f841736b: Wallet: Do not allow bumpfee to backdate the replacement transaction lockitme
nit:
Commit subject and body say "lockitme". Should be "locktime".
Commit body says "This changes change the behavior". It should be "This changes the behavior".
b7935c708edc225e20dcab0820dff774f841736b: Wallet: Do not allow bumpfee to backdate the replacement transaction lockitme
nit
b7935c708edc225e20dcab0820dff774f841736b: Wallet: Do not allow bumpfee to backdate the replacement transaction lockitme
There's an OBO in this logic. In the inclusive range
[minimum_height, block_height]there are(block_height - minimum_height) + 1possible values.randrange(block_height - minimum_height)only drawsblock_height - minimum_heightpossible values and can never pick theminimum_heightvalue.Also, when
minimum_height == 0, we retain the prior behavior and backdate at most 99 blocks from tip. Whenminimum_height > 0, we should use the full inclusive window without the 100 block cap.b7935c708edc225e20dcab0820dff774f841736b: Wallet: Do not allow bumpfee to backdate the replacement transaction lockitme
In the case where we're fee bumping an already-nLockTimed tx, we should not reset its
nLockTimeback below that establishedminimum_height. Otherwise we fingerprint the tx.minimum_heightdefaults to 0, so new sends on a stale chain still retain the prior behavior ofnLockTime = 0.In the case where the
minimum_heightis ahead of the local tip, setnLockTime = 0b7935c708edc225e20dcab0820dff774f841736b: Wallet: Do not allow bumpfee to backdate the replacement transaction lockitme
Approach ACK
reviewed f26586b91de16a03d4c265a7e8ee9fefb728dd65
in f26586b91de16a03d4c265a7e8ee9fefb728dd65 there as a typo in the commit message. It ends with - should be a .
in b7935c708edc225e20dcab0820dff774f841736b Wallet: Do not allow bumpfee to backdate the replacement transaction lockitme
nit: missing space between ) and {
in b7935c708edc225e20dcab0820dff774f841736b Wallet: Do not allow bumpfee to backdate the replacement transaction lockitme
Is this if needed? can we have a
block_heightsmaller than theminimum_height? I think at least we will always be at theminimum_height, I can only think of a re-org, but then we must swich to a chain with more PoW so the height will likely be higher too.Also I think this can be simplified into:
This version I propose has several improvements:
block_height - minimum_height.in b7935c7 Wallet: Do not allow bumpfee to backdate the replacement transaction lockitme
nit: again, space between ) and {
in b7935c7 Wallet: Do not allow bumpfee to backdate the replacement transaction lockitme
nit: this is over indented, there are 8 spaces instead of 4.
in f26586b Test: bumpfee does not backdate the locktime
The test is weak, if the backdating code is broken and it does not backdate, this loop would run forever and never fail. Probably should add a big max num of tries so if after N iterations it did not pass, we can assume the code is wrong.
I would suggest a unit test for the function anyway, that way we can just test the backdating function.
in f26586b91de16a03d4c265a7e8ee9fefb728dd65 Test: bumpfee does not backdate the locktime
Missing commas between arguments, probably True con go with
verbose=Trueso it is easier to understand.Concept ACK.
I think this can be simplified by enforcing the replacement-specific invariant in
CreateRateBumpTransaction()(feebumper.cpp), after creation and before signing. It avoids adding state to CCoinControl, preserves the existing random distribution, and covers stale andprevious_locktime > block_heightcases that the current implementation misses.The test appears flaky:
current_heightis incremented without mining, so the loop exits after one iteration, and unpatched code could pass often.CCoinControldescribes how a new transaction should be constructed - butm_previous_locktimeis different. A normal transaction has no previous transaction. The concept exists only becauseCreateRateBumpTransaction()is constructing an RBF replacement.There is a hidden coupling now. The generic transaction builder must now understand a fee-bumping detail => maintenance complexity later.
What if we try to find better ownership for this fee-bump-specific improvement? The fee-bumper already possesses both values, so it could enforce the relationship locally:
The generic builder creates a normal transaction. The fee-bumper then applies the replacement-specific invariant before signing.
When
minimum_heightis greater, nothing happens. The transaction keeps the already assignedblock_height,, which is below the declared minimum.This can happen, for example, if:
invalidateblock.A true lower-bound implementation would retain the original distribution.
Example:
rng_fast.randrange(50)=> 0...49.Therefore, the subtraction can never reach or cross
minimum_height.Suppose the original tx
nLockTimeis 96400. The node goes offline for more than 8 hours, and the user callsbumpfee. The PR passes 9640 intoDiscourageFeeSniping()but the chain considered stale, so the execution goes directly totx.nLockTime = 0;.Therefore:
Small chance to that the test can pass with the unpatched code, when the first nonzero random backdate is only one or two blocks.
The idea here is to avoid backdating when using
bumpfee, without making these changes distinguishable from other transactions that use antifee sniping. If we were to use onlyminimum_heightas the inclusive window, we could end up with replacements with a locktime more than 100 blocks behind the current tip. That would be easily fingerprintable as coming from Core, which is exactly what we want to avoid.The only time when this can happen is if the node is still downloading blocks or if the last block is from more than 8 horus ago. This males the
block_heightunrelaibale to compre and it could happen thatminimum_heightis greater than theblock_heightbeacuse we don't have blockchain up to date. This could lead to setting a transaction with a locktime to 0 because even thoughminimum_heightis less than the current block tip becasue the blockhain is not up to date. Example: We have the originstl transactiontxAwith locktime 12. The current tip is 15 but the node has only downloaded till 10. If we replace the transaction, that would set the locktime to 0 (sinceminimum_heightis 12 andcurrent_heightis 10), and with that logic this would tell that the node is not up to date. Plus I do not belive that setting the rpelacement set to 0 fingerprints the transactions as there are lots of wallets than when bumping fee set the locktime to 0.But that would disable the antifee sniping completly, wouldn't it be beeter to leave the locktime in thecurrent_tip? That way we are still antifee sniping.If the original transaction has a final sequence number and a locktime greater than the current tip, the locktime is not enforced because of the sequence number, so the transaction is valid with a locktime far greater than the current tip. This would make
minimum_heightin the replacement greater than the current tip. This is the only case I can think of. The other solution would be to check the sequence number of the original transaction.I'm not sure if doing it like this is a good idea. When backdating, if we apply this, the Discuragefeesniping will give a locktime between the
[current_height, current_height-100], and most of the times this locktime will be older than the previous locktime since most of replacements are done after a few blocks. That means that we will have either a replacement transaction with a locktime set on the current_height or on the previous lockitme most of the time. If we keep the current logic, we'll have a more diverse distribution of locktimes for replacement transactions.Fixed in c72998bc4e
Thanks for the reviews!
Discuragefeesnipingand at the same time fixing the OBO problem.verbose=TrueFor now putting the pr as a draft. Seeing some of the feedback I see now that the functional test is weak and that a unit test is better. Once the unit test is completed I will open the pr again.
During this time, feel free to respond to my replies to your comments so we can agree on the best approach.
I think that is how it should be. See my previous answer: https://github.com/bitcoin/bitcoin/pull/36040#discussion_r3879830139
You're right about this one, otherwise we would be setting a locktime older than the original transaction.
Yes, you're rigth. I will fix it.
I think this makes sense. For example:
txAwithlocktime = 15txAis not included in any, but we fall behind the tipminimum_height = 15. Here we could either: a) set txB's locktime to0, or b) set txB's locktime tominimum_heightIf we go with a), an observer would say that we are either:
In the imaginary future where we all use the same exact anti-fee sniping strategy, 1. doesn't exist, and the observer would notice we're not synced to the tip
If we go with b), an observer would say that we are either:
The reason 2. wouldn't exist in case a) is that it's pretty weird that in a protocol that uses locktime, a txA has a locktime, but its replacement doesn't.
I agree with the axiom of
replacement.nLockTime >= original.nLockTimein any case. Good privacy strategy: do not reveal more than you already had, if possible.Following that, the solution of setting
replacement.nLockTime = original.nLockTimepreserves the information already visible in the original, while other solutions introduce a new, unusual transition - since we cannot do better because our chain is stale.Fair point—the
std::max()example may not be the right implementation.My main point was architectural rather than about that exact implementation. What do you think about keeping this replacement-specific behavior in
CreateRateBumpTransaction()? The fee-bumper owns both the original and replacement transactions and therefore knows the invariant it must enforce.We could still generate the locktime using the desired distribution, possibly through a shared helper, while avoiding
m_previous_locktimein the genericCCoinControland keeping the generic transaction builder unaware of RBF history.I'd rather keep all the anti fee sniping logic inside the
Discuragefeesniping. I think this way it is easier to follow the code and not delegate part of this logic outside the function because of the RBF case. I feel that otherwise we would be duplicating code when the current approach just needs them_previous_locktimeinCCoinControl.🚧 At least one of the CI tasks failed.
Task
OpenBSD Cross: https://github.com/bitcoin/bitcoin/actions/runs/34280727979/job/102244563839LLM reason (✨ experimental): CI failed due to a Clang build error from
-Wthread-safety-analysis/-Werrorinwallet/test/spend_tests.cpp(callingchainman->ActiveChain()without exclusively holdingcs_main).Hints
Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:
Possibly due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.
A sanitizer issue, which can only be found by compiling with the sanitizer and running the
affected test.
An intermittent issue.
Leave a comment here, if you need help tracking down a confusing failure.
Changes made:
cc8f4784cf: I adpoted @nervana21 suggestion. Now we don't reset thenLocktimebelow the establishedminimum_heighteven if we are on a stal chain. The only case when we reset thenlocktimeto 0 is if theminimum_heightis higher than the currentblock_height. In this case, we set it to 0.903d2bfa67: I've eliminated the functional test and added a unit test in thespend_tests.cppof the wallet. I added the following cases:[minimum_height, block_height]).minimum_height. This way we prove that the OBO error is not there and also check that when calculating therangeinspend.cppthis is not 0 as this would cause an error later onrng_fast.randrange(range).minimum_height>block_height. In this case we set the locktime to 0.minimum_height<=block_height, in this case we set the locktime tominimum_heightminimum_height>block_height, in this case we set the locktime to 0.I looked more closely at the approach I suggested. Although it separates the replacement-specific behavior a bit more cleanly and avoids adding a field to
CCoinControl, it introduces complexity elsewhere.Your approach fits the existing code structure better, and I think the extra complexity of the separation outweighs its benefits here.
Thanks for taking the time to consider it.
Concept ACK.
I ran all new and modified tests locally, and they passed. I've left my test-related comments inline.
nit:
With
minimum_height == 0, this also changes the locktime distribution for ordinary sends when the chain height is below 99, short chains (like regtest).For example, at height 2, the old code samples an offset from
[0, 99]and clamps negative results to zero. Within the 10% random branch, offset 0 gives locktime 2, offset 1 gives locktime 1, and offsets 2–99 all give locktime 0. Zero therefore has a 98% probability within that branch.The new code samples an offset from
[0, 2], so locktimes 0, 1, and 2 each have a one-third probability within the random branch. The possible locktimes are the same, but their probabilities are different. The 90% branch that uses the current height is unchanged.Is this intentional? I think this is good as it is, I just wanted to point out the change.
Could you add a case with
minimum_heightgreater than 99 blocks below the tip? The current tests use gaps of only 1 and 10 blocks, so they wouldn't catch the removal of the 100-value cap. On a current chain, the locktime should still stay within[block_height - 99, block_height].Could you add a test covering the full modified path, starting with passing the original locktime through
CCoinControl? The current tests callDiscourageFeeSniping()directly, so they would still pass if the original locktime were no longer forwarded.A wallet unit test that calls
CreateRateBumpTransaction()should be enough. Using a stale tip and an original height-based locktime below the tip would make the check deterministic: the replacement should retain the original locktime rather than fall back to zero.Could we use an explicitly fixed RNG seed here and verify that the resulting sequence reaches the minimum within the iteration limit? The test can fail even with correct code if none of the 200 attempts succeed (even though the chances are low - thinking long term).
903d2bfa67: Test: bumpfee does not backdate the locktimenit: these should be alphabetized with the rest of the includes
903d2bfa67: Test: bumpfee does not backdate the locktimeWould it make sense to strengthen this test to check not only that we backdated but also check that we left the locktime unchanged?
Thanks for taking the suggestions. I've left just a few more comments.
903d2bfa67: Test: bumpfee does not backdate the locktimenit: wording
I didn't though of that case, but I don't think it matters since in new chains you can start spending the UTXOs in block 101, and by then this is not a problem anymore.
Done! Added a test in feebumper_test.cpp which bumps a transaction directly through
CreateRateBumpTransaction.Yes, I think it makes sense to use a fixed rng seed. Thanks for pointing it out!
Done! I modified the
discourage_fee_sniping_backdating_boundsfirst test so theminimum_heightis greater than the 100 block limit.Yes, I think it doesnt hurt and makes the test more robust.
Done!
Thanks again for the reviews!
b72a0533da:feebumper_test.cpp(since we use feebumper logic) which bumps a transaction directly throughCreateRateBumpTransaction. As suggested by @molnard, we do it on a stale chain so we can check if the previous lockitme is propagated to the new tx.discourage_fee_sniping_backdating_boundsI added a fixed rng seed and modified the first test so theminimum_heightis greater than the 100 block limit.saw_tip_locktimecheck suggested by @nervana21ACK
b72a0533dawith nits.The code looks good. I've left a couple of minor comments on the tests.
Shouldn't this be
[block_height - 99, block_height]?randrange(100)returns values from 0 to 99, so the maximum backdate is 99 blocks. Including the current height, that gives 100 possible locktimes.The
BOOST_CHECK_GEbelow should also useblock_height - 99; otherwise it allows a 100-block backdate.Could we remove the
breakand run all 200 iterations? This would check more generated locktimes against both bounds and could catch regressions from future changes that the early exit would miss. We can still checkbackdatedandsaw_tip_locktimeafter the loop.For example, with the current fixed seed, the first four locktimes are
111, 111, 111, 17, even if we remove thestd::min(100, ...)cap. The loop exits there and misses the regression. In a standalone reproduction using Core's RNG, continuing the loop catches a violation of the 99-block bound on call 37.b72a0533da: Test: bumpfee does not backdate the locktimeSince we're only dealing with a single coinbase coin, I think this can be simplified.
b72a0533da: Test: bumpfee does not backdate the locktimenit
b72a0533da: Test: bumpfee does not backdate the locktimeas above
True, I got confussed when writing the comments. Thnaks!
Agreed, it makes sense.
True, thisway is better. Thanks!
Done!
Done!
Changes made:
bump_transaction_fee_sniping_checktest in feebumper_test as suggested by @nervana21discourage_fee_sniping_backdating_boundsI eliminated the breaks and change the 100 for a 99 as @molnard suggested.ACK
e34f9340d6Checked the code and ran the tests - all good.
675448e262: Wallet: Do not allow bumpfee to backdate the replacement transaction locktimenit
675448e262: Wallet: Do not allow bumpfee to backdate the replacement transaction locktimeFor this commit message:
lockitme -> locktime
greter -> greater
tACK
e34f9340d6left minor, non-blocking nits
tACK
e34f9340d6Reviewed the code and ran all tests locally.
Addressed @nervana21 nits. Just minor changes:
spend.hACK
8836a3643btACK
github.com/bitcoin/bitcoin@8836a3643bIn
7049f9ba51"Wallet: Do not allow bumpfee to backdate the replacement transaction locktime"I suggest calling this
minimum_locktimerather thanprevious_locktimeas it's use could be for more than just dealing with replacements.In
7049f9ba51"Wallet: Do not allow bumpfee to backdate the replacement transaction locktime"Discussing replacements is unnecessary in this function. This does not need to care about what the callers are.
In
7049f9ba51"Wallet: Do not allow bumpfee to backdate the replacement transaction locktime"Same comment regarding referencing replacements.
In
7049f9ba51"Wallet: Do not allow bumpfee to backdate the replacement transaction locktime"This should be below inside of
if (use_anti_fee_sniping).In
8836a3643b"Test: bumpfee does not backdate the locktime"This does not need to be a unit test. For wallet things, we prefer functional tests over unit tests wherever possible.
Addressed all the comments and suggestions by @achow101:
fae0b2cb06: As suggested, I changed the varible name fromm_previous_locktimetom_minimum_locktime. Also changed the comments inspend.cppto avoid disccusing replacements. Inspend.cppchanged a condition so it is insideif (use_anti_fee_sniping).bf80b5a711: Changed thebump_transaction_fee_sniping_checkunit test to functional. I modified a little the approach: Create a transaction with a locktime older by 101 blocks and then replaced it with a stale tip so the lcoktime in the replacement is the same as the original. As explained in the test, I choose to create a tx with an explicit locktime 101 blocks below the current height beacuse antifee sniping normally sets the locktime to the current height, or it backdates it by a random 0-100 blocks. So a locktime 101 blocks older can't be produced by either, so if the bumped tx has this locktime, we know it was copied from the original transaction rather than recomputed by anti-fee-sniping.Created a functional test in
wallet_bumfee.py🔵 Suggestion · Fee-bump locktime overrides use a process-fatal check
Although no current caller setting
m_locktimewas found, passing it through the fee-bump interface would terminate the process instead of returning a request error.Location:
src/wallet/feebumper.cpp:323(head).🔵 Suggestion · Timestamp-locktime originals are missing from bump coverage
The new tests miss the height/timestamp filter, so they would not catch its removal giving timestamp-locktime originals replacement locktime 0 on a fresh tip.
Location:
test/functional/wallet_bumpfee.py:912(head).🔵 Suggestion · Locktime comments overstate the minimum and backdating bounds
The new comments describe a general minimum and a 99-block bound, but the field only controls anti-fee-sniping heights and stale tips can preserve an older locktime.
Location:
src/wallet/coincontrol.h:118(head).🔵 Suggestion · Add a release note for the bumpfee locktime change
feebumper.cpp:322-324 changes the locktime of bumpfee replacements, a user-visible change, but there is no doc/release-notes-36040.md; developer-notes.md asks for PR-specific release notes for visible user-facing changes.
Location:
src/wallet/feebumper.cpp:322(head).🔵 Suggestion · Test the minimum-locktime equality boundary
A single fresh-tip minimum_height == block_height check was added (spend_tests.cpp:181-183). The stale-tip test still lacks an equality case asserting the locktime equals minimum_height rather than 0, so that boundary is not covered.
Location:
src/wallet/test/spend_tests.cpp:181(head).Review coverage was incomplete.
Reviewed:
596dd6fd88ef· Full review report · Previous reportspermalink
Stopped at
fae0b2cb06(Wallet: Do not allow bumpfee to backdate the replacement transaction locktime)Still mentions previous locktime
Stopped at
fae0b2cb06(Wallet: Do not allow bumpfee to backdate the replacement transaction locktime)Should also be inside of
if (use_anti_fee_sniping)Done!
a6bc933b3fchanged the commets so previous locktime is not metioned. Also changed the comment incointcontrol.hfrom//! Save the previous locktime for replacementsto//! Minimum locktime for the transaction being created.I think we could improve the test coverage.
Functional tests only test the stale tip branch, we should also test that a normal replacement never falls below its original height locktime.
For unit tests it is testing a minimum one block below the tip, but what about
minimum_height == block_height? That case can be added for current and stale tips.in
a6bc933b3fWallet: Do not allow bumpfee to backdate the replacement transaction locktimeThis is not true at all, it is only an optional anti-fee-sniping minimum timestamp value. The comment seems to indicate it is always taken into account, but it can be overwritten by an explicit locktime.
in
a6bc933b3fWallet: Do not allow bumpfee to backdate the replacement transaction locktimeThis if statement is unnecessary as we never set a manual locktime when replacing. So we should always store the locktime as the minimum one.
in
a6bc933Wallet: Do not allow bumpfee to backdate the replacement transaction locktimeblock_heightandminimum_heightmixes signed and unsiged values before casting the result toint. I think using consistent types make that safety easier to verify.in
a6bc933b3fWallet: Do not allow bumpfee to backdate the replacement transaction locktimenit: empty jump line
in
a6bc933Wallet: Do not allow bumpfee to backdate the replacement transaction locktimenit: I don't think this comment is useful at all, it is indeed saying nothing, the code is self-explainatory.
in
a6bc933Wallet: Do not allow bumpfee to backdate the replacement transaction locktimebelow the best known tip.Maybe we don't know the tip or we are stale and we backdate more than 99blocks from the real tip.
in
ced45ea971Test: bumpfee does not backdate the locktimeThe range in the comment is wrong, it should be
a random 0-99 blocks.in
ced45ea971Test: bumpfee does not backdate the locktimeThis is not restoring the mocktime. You should not use the tip timestamp but the node mocktime. I think you can store
rbf_node.mocktimeand restore to that value.Concept ACK
What is 11? :-) It might be even better if we know that 11 blocks are created on top of the current 100-block tip
I think it self explanatory that is an optional parametet given that it is a
std__optional. On a previous version I mentioned that this is for replacemetns transactions, but other reviwers mentioned that it is better to not mention the replacements in the comments, so I am a bit unsure to put this is for anti fee sniping in the comment.Done! Instead of declaring anew variable, I updeted the code with some comments that explain the reason of the extra 11 blocks.
Now we use
static_castto pass the variable tointin the line 1029.Feedback addressed!
aecdce2ac2I cleaned the code a little bit and updated some comments.76a55ec1d0I added some coments in the unit test to explain why we mine 11 blocks. In the functional test I updeated the comment so the range is correct (0-99). Also changed lokctime subtraction from 101 to 100.I've just seen there are some conflicts in
wallet_bumpfee. I will address them as soon as I can.🐙 This pull request conflicts with the target branch and needs rebase.
I couldn't do it with rbf_node.mocktime, so following examples from other tests I saved the time using
int(time.time())Rebased
The implementation looks good to me, left a few comments on the testing part before acking it :)
in
ec91996Test: bumpfee does not backdate the locktimeProbably worth to check that setting the minimum locktime to the tip does not backadate.
in
ec9199610bTest: bumpfee does not backdate the locktimeI think the test is missing some coverage, it only asserts what happens with a stale tip.
Probably an easy way to test what happens with a fresh tip would be somemetihng like:
in
ec9199610bTest: bumpfee does not backdate the locktimeI think this is wrong. This is hardcoding a specific timestamp to the node. If
curr_time = int(time.time())was stored at time 2. Andrbf_node.setmocktime(curr_time)was executed at time 5, the node clock will be set to time 2.Instead of using time, probably you should store the node mocktime itself, and if there is no mocktime hardcoded, just set it to 0 which means use the system clock. See
test_node.pyL479.I would probably prefer something like:
rbf_node.mocktimeis None untilsetmocktimeis used. So we could either set the mocktime with thetip_timeor to 0 (None), as you said. I've opted for putting it back to 0.Feedback from @polespinasa addressed! Adopted its suggestions on the tests!
ACK
596dd6fd88Thanks for addressing feedback, lgtm now :)
ACK
596dd6fd88ACK
596dd6fd88