Skip to content

ToExpirationSeconds turns an expired monitoring window into a one-second session #146

Description

@chavic

PayjoinUriSessionService.ToExpirationSeconds clamps the remaining monitoring time to a floor of one second:

var remainingSeconds = (monitoringExpiresAt - DateTimeOffset.UtcNow).TotalSeconds;
if (remainingSeconds < 1d)
{
    return 1UL;
}

So when monitoringExpiresAt is already in the past, BuildAsync still builds the receiver session, registers it with the directory, and that session expires one second later.

The path is hard to reach. The availability checks run before session creation, and an expired invoice normally fails one of them first. The problem is that the clamp hides the condition instead of reporting it. The result is a session that dies at birth, a confusing log trail, and a directory registration that serves no purpose.

InvoiceNotPayable now exists in PayjoinAvailabilityStatus, so refusing with a reason is straightforward. A test with a past monitoringExpiresAt would pin it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions