Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ private async Task<CreateSenderPsbtResult> CreateSenderPsbtAsync(SystemUri payme
paymentAmount = Money.Satoshis(checked((long)amountSats.Value)).ToDecimal(MoneyUnit.BTC);
using var _ = parsedUri.CheckPjSupported();
}
catch (PjParseException ex)
catch (UriParseException ex)
{
throw new InvalidOperationException($"Invalid BIP21 URI '{paymentUrl}': {ex.Message}", ex);
}
Expand Down Expand Up @@ -233,9 +233,9 @@ private async Task<PSBT> RequestProposalAsync(SystemUri paymentUrl, IReadOnlyLis
}
proposalPsbtBase64 = await PollForProposalAsync(current, senderPersister, ohttpRelayUrls, cancellationToken).ConfigureAwait(false);
}
catch (SenderPersistedException.ResponseException ex)
catch (SenderPersistedException ex) when (SenderResponseOf(ex) is { } senderResponse)
{
throw CreateSenderResponseFailure(ex);
throw CreateSenderResponseFailure(ex, senderResponse);
}

if (string.IsNullOrWhiteSpace(proposalPsbtBase64))
Expand Down Expand Up @@ -355,13 +355,23 @@ private async Task<PSBT> RequestProposalAsync(SystemUri paymentUrl, IReadOnlyLis
throw new InvalidOperationException($"All configured OHTTP relays failed for payer store '{_payer.StoreId}'. LastError='{lastError?.Message}'", lastError);
}

private InvalidOperationException CreateSenderResponseFailure(SenderPersistedException.ResponseException ex)
private InvalidOperationException CreateSenderResponseFailure(SenderPersistedException ex, global::Payjoin.ResponseException senderResponse)
{
return new InvalidOperationException(
$"Payjoin receiver rejected the proposal for payer store '{_payer.StoreId}': {FormatSenderResponseException(ex.v1)}",
$"Payjoin receiver rejected the proposal for payer store '{_payer.StoreId}': {FormatSenderResponseException(senderResponse)}",
ex);
}

private static global::Payjoin.ResponseException? SenderResponseOf(SenderPersistedException exception)
{
return exception switch
{
SenderPersistedException.Fatal { v1: SenderException.Response response } => response.v1,
SenderPersistedException.Transient { v1: SenderException.Response response } => response.v1,
_ => null
};
}

private static string FormatSenderResponseException(global::Payjoin.ResponseException responseException)
{
return responseException switch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ private sealed class FixedPsbtProposal(string psbt) : IPayjoinProposal
public RequestResponse CreatePostRequest(string ohttpRelay) => throw new NotSupportedException();
public PayjoinProposalTransition ProcessResponse(byte[] body, ClientResponse ohttpContext) => throw new NotSupportedException();
public string Psbt() => psbt;
public PayjoinOutPoint[] UtxosToBeLocked() => throw new NotSupportedException();
public bool ProposalTxidIsStable() => throw new NotSupportedException();
}

private sealed class NoOpSessionProcessor : IPayjoinReceiverSessionProcessor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ private sealed class FixedPsbtProposal(string psbt) : IPayjoinProposal
public RequestResponse CreatePostRequest(string ohttpRelay) => throw new NotSupportedException();
public PayjoinProposalTransition ProcessResponse(byte[] body, ClientResponse ohttpContext) => throw new NotSupportedException();
public string Psbt() => psbt;
public PayjoinOutPoint[] UtxosToBeLocked() => throw new NotSupportedException();
public bool ProposalTxidIsStable() => throw new NotSupportedException();
}

private sealed class ThrowingProposal : IPayjoinProposal
Expand All @@ -179,7 +179,7 @@ private sealed class ThrowingProposal : IPayjoinProposal
public RequestResponse CreatePostRequest(string ohttpRelay) => throw new NotSupportedException();
public PayjoinProposalTransition ProcessResponse(byte[] body, ClientResponse ohttpContext) => throw new NotSupportedException();
public string Psbt() => throw new NotSupportedException();
public PayjoinOutPoint[] UtxosToBeLocked() => throw new NotSupportedException();
public bool ProposalTxidIsStable() => throw new NotSupportedException();
}

private sealed class UnusedRelayRequestSender : IPayjoinReceiverRelayRequestSender
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public async Task<ActionResult<RunTestPaymentResponse>> RunTestPayment([FromBody
paymentAmount = Money.Satoshis(checked((long)amountSats.Value)).ToDecimal(MoneyUnit.BTC);
using var _ = parsedUri.CheckPjSupported();
}
catch (PjParseException ex)
catch (UriParseException ex)
{
return RunTestPaymentFailure($"Invalid BIP21 URI: {ex.Message}");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private static bool IsPayjoinEnabled(string paymentUrl)
using var _ = parsedUri.CheckPjSupported();
return true;
}
catch (PjParseException)
catch (UriParseException)
{
return false;
}
Expand Down
16 changes: 13 additions & 3 deletions BTCPayServer.Plugins.Payjoin/Services/RunTestPaymentService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,13 @@ private async Task<PSBT> RequestProposalAsync(
current.Dispose();
}
}
catch (BuildSenderException ex)
catch (SenderInputException ex)
{
throw new RunTestPaymentExecutionException($"Sender build failed: {ex.Message}", ex);
}
catch (SenderPersistedException.ResponseException ex)
catch (SenderPersistedException ex) when (SenderResponseOf(ex) is { } senderResponse)
{
throw new RunTestPaymentExecutionException($"Sender rejected by receiver: {FormatSenderResponseException(ex.v1)}", ex);
throw new RunTestPaymentExecutionException($"Sender rejected by receiver: {FormatSenderResponseException(senderResponse)}", ex);
}
catch (HttpRequestException ex)
{
Expand Down Expand Up @@ -442,6 +442,16 @@ private static IReadOnlyList<SystemUri> GetConfiguredRelayUrls(RunTestPaymentCon
throw new RunTestPaymentExecutionException("No OHTTP relays configured for test payment.");
}

private static global::Payjoin.ResponseException? SenderResponseOf(SenderPersistedException exception)
{
return exception switch
{
SenderPersistedException.Fatal { v1: SenderException.Response response } => response.v1,
SenderPersistedException.Transient { v1: SenderException.Response response } => response.v1,
_ => null
};
}

private static string FormatSenderResponseException(global::Payjoin.ResponseException responseException)
{
return responseException switch
Expand Down
2 changes: 1 addition & 1 deletion rust-payjoin
Submodule rust-payjoin updated 100 files
Loading