boltlabs-inc / zeekoe

Zero-knowledge layer-2 payment channels
MIT License
24 stars 1 forks source link

Add payment validation before initiating pay session #334

Open marsella opened 3 years ago

marsella commented 3 years ago

Right now, a payment isn't rejected for not-enough-balance until the customer tries to form a pay proof. This is very late and puts the customer into a difficult-to-recover state. Also, there's a weird situation where a payment is initiated (the non-zkabacus bits) but the customer status doesn't change until it gets to zkabacus parts. This could result in a "race" where both payments get approved but only one gets executed.

Instead, the pay session should do the following

  1. Set status to pending payment
  2. Check whether there's enough balance. If not, return status to Ready
  3. If so, continue.
  4. When zkabacus starts, update state from PendingPay, not from Ready.