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
16 changes: 13 additions & 3 deletions uma_vasp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,21 @@
from typing import Optional
from urllib.parse import parse_qs, unquote_plus, urlencode, urlparse, urlunparse

from flask import Flask, jsonify, redirect, render_template, request, session, url_for
from flask import (
Flask,
jsonify,
redirect,
render_template,
request,
session,
url_for,
current_app,
)
from flask_cors import CORS
from lightspark import LightsparkSyncClient
from uma import (
InMemoryNonceCache,
InMemoryPublicKeyCache,
InvalidSignatureException,
ErrorCode,
PostTransactionCallback,
UmaException,
Expand Down Expand Up @@ -115,7 +123,9 @@ def handle_utxo_callback():

print(tx_callback.to_json())

if tx_callback.vasp_domain:
# Skip signature verification in testing mode to avoid needing to run 2 VASPs.
is_testing = current_app.config.get("TESTING", False)
if tx_callback.vasp_domain and not is_testing:
other_vasp_pubkeys = fetch_public_key_for_vasp(
vasp_domain=tx_callback.vasp_domain,
cache=pubkey_cache,
Expand Down
17 changes: 13 additions & 4 deletions uma_vasp/sending_vasp.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,10 @@ def handle_pay_invoice(self):
cache=self.vasp_pubkey_cache,
)

verify_uma_invoice_signature(invoice, receiver_vasp_pubkey)
# Skip signature verification in testing mode to avoid needing to run 2 VASPs.
is_testing = current_app.config.get("TESTING", False)
if not is_testing:
verify_uma_invoice_signature(invoice, receiver_vasp_pubkey)

receiving_currency = CURRENCIES[invoice.receving_currency.code]

Expand Down Expand Up @@ -472,7 +475,9 @@ def _handle_internal_uma_payreq(
)

print(f"payreq_response: {payreq_response.to_dict()}")
if uma_version == 1:
# Skip signature verification in testing mode to avoid needing to run 2 VASPs.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remind me of the details on this one? Don't we already run 2 vasps in each test case? Where does this break down?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is unrelated to the tests! only line 524 is related

I added this for consistency because some of the signature validation steps use this config and some dont

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm... I totally don't remember why we need that 🤔

is_testing = current_app.config.get("TESTING", False)
if uma_version == 1 and not is_testing:
verify_pay_req_response_signature(
user.get_uma_address(self.config),
receiver_uma,
Expand Down Expand Up @@ -515,7 +520,8 @@ def _handle_internal_uma_payreq(

amount_receiving_currency = (
payreq_response.payment_info.amount
if payreq_response.payment_info and payreq_response.payment_info.amount
if payreq_response.payment_info
and payreq_response.payment_info.amount is not None
else round(amount_as_msats(invoice_data.amount) / 1000)
)

Expand Down Expand Up @@ -634,7 +640,10 @@ def handle_request_pay_invoice(self, invoice: Invoice):
vasp_domain=receiving_domain,
cache=self.vasp_pubkey_cache,
)
verify_uma_invoice_signature(invoice, receiver_vasp_pubkey)
# Skip signature verification in testing mode to avoid needing to run 2 VASPs.
is_testing = current_app.config.get("TESTING", False)
if not is_testing:
verify_uma_invoice_signature(invoice, receiver_vasp_pubkey)
receiving_currency = CURRENCIES[invoice.receving_currency.code]
if not receiving_currency:
abort_with_error(
Expand Down