Page MenuHomePhabricator

[backport#16624 1/4] Encapsulate tx status in a Confirmation struct

Authored by majcosta on Mon, Jul 27, 19:18.



Instead of relying on combination of hashBlock and nIndex
values to manage tx in its lifecycle, we introduce 4

hashBlock and nIndex magic values should only be used at
serialization/deserialization for backward-compatibility.

At block disconnection, we know flag txn as UNCONFIRMED where
previously they kept their states until being override by a
block connection or abandontransaction call. This is a change
in behavior for which user may have to call abandon twice
if transaction is disconnected and not accepted back in the mempool.

We assert status transitioning right in AddToWallet. Doing so
flagged a misbehavior in ComputeTimeSmart unit test where same
tx is confirmed twice in different block. To avoid inconsistencies
we unconfirmed tx before new connection in different block. We
also remove a cs_main lock in test, as AddToWallet and its
callees don't rely on locked chain.

Partial backport of Core PR16624

Test Plan
ninja check check-functional

Diff Detail

rABC Bitcoin ABC
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

majcosta created this revision.Mon, Jul 27, 19:18
Herald added a reviewer: Restricted Project. · View Herald TranscriptMon, Jul 27, 19:18
teamcity edited the summary of this revision. (Show Details)Mon, Jul 27, 22:05

[Bot Message]
One or more PR numbers were detected in the summary.
Links to those PRs have been inserted into the summary for reference.

Fabien accepted this revision.Tue, Jul 28, 09:13
Fabien added a subscriber: Fabien.
Fabien added inline comments.
564 ↗(On Diff #22536)

Nit: layout

This revision is now accepted and ready to land.Tue, Jul 28, 09:13