Handle failed payment (#302)

* Show popup error message when payment failes

* Remove log lines from pay offer backend method
This commit is contained in:
Jonathan Zernik 2020-10-18 19:29:14 -04:00 committed by GitHub
parent e29f5f174c
commit 3b284ab699
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View file

@ -44,10 +44,10 @@ export default function OpenChannelDialog({
var classes = useStyles();
const history = useHistory();
var [amount, setAmount] = useState(0);
var [amount, setAmount] = useState("");
const resetFields = () => {
setAmount(0);
setAmount("");
};
const handleChangeAmount = (event) => {

View file

@ -274,6 +274,9 @@ class SqueakNode:
payment = self.lightning_client.pay_invoice_sync(offer.payment_request)
preimage = payment.payment_preimage
if not preimage:
raise Exception("Payment failed with error: {}".format(payment.payment_error))
# Check if preimage is valid
preimage_hash = sha256(preimage).hexdigest()
is_valid_preimage = (preimage_hash == offer.payment_hash)