Skip to content

fly_client: inverted kernel validity check in ProofKernel2 handling breaks swap redeems #2073

Description

@Maxnflaxl

Bug
FlyClient::NetworkStd::Connection OnMsg(ProofKernel2) handling in core/fly_client.cpp (~line 1165):

if (req.m_Res.m_Kernel->IsValid(req.m_Res.m_Height))
    ThrowUnexpected();

The condition is inverted — it throws when the returned kernel IS valid. Every sibling check in the file, including the Kernel3 branch immediately below (if (!req.m_Res.m_Kernel->IsValid(...)) ThrowUnexpected();), throws on !IsValid. Introduced by 7a38b48 ("proto: added GetProofKernel3") while refactoring the pre-existing code, which used !IsValid.

Impact
The fetched-kernel path of RequestKernel2 is exercised by atomic-swap redeem-secret extraction: the wallet fetches the counterparty's redeem kernel to extract the shared secret. With the inverted check every valid response kills the node connection (ThrowUnexpected), the wallet reconnects and retries forever — swap redeems hang. Unnoticed because swap_test has been disabled in wallet/unittests/CMakeLists.txt since 2023; resurrecting it hangs on the first full-swap scenario and passes with the ! restored.

Part of #2070.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions