Closed mkurapov closed 4 months ago
@mkurapov how do you imagine flow here? So when should ASE perform balance check and call cancelOutgoingPayment
in case there is not enough balance?
I assume that this check needs to be performed when ASE receives outgoing_payment.created
webhook right?
@golobitch exactly,
outgoing_payment.created
webhookfundOutgoingPayment
cancelOutgoingPayment
Context
Currently, when we create an outgoing payment, we send a
outgoing_payment.created
webhook to the ASE such that the ASE can check the user account, place a hold on the account for the payment amount, and then callfundOutgoingPayment
, to deposit liquidity into the payment. Then, the ILP payment starts sending into the incoming payment.Sometimes, however, the sending user account may not have enough balance to fulfill the outgoing payment amount. Rafiki does not provide a way for the ASE to notify about this possibility, and as a result, the outgoing payment will indefinitely stay in a FUNDING state.
We should allow the ASE to notify Rafiki about this possibility through a new Admin API,
cancelOutgoingPayment
(name always up for discussion).cancelOutgoingPayment
will take in theoutgoingPaymentId
and update the state of the outgoing payment to a new stateCANCELLED
.The only time an outgoing payment can be marked CANCELLED is if it is in a FUNDING state. Make sure to also update the
OutgoingPayment.failed
getter in the model to include this state, so that we properly returnfailed: true
when it is fetched via Open Payments. Also, there is no need to send a webhook when an outgoing payment has been cancelled.Todos
cancelOutgoingPayment
mutationOutgoingPaymentState
enum in the GraphQL API