connext / indra

[LEGACY] Monorepo containing everything related to the core Connext protocols and network.
MIT License
84 stars 38 forks source link

[Meta] Support ASYNC_TRANSFER application for payments to offline recipients #334

Closed ArjunBhuptani closed 4 years ago

ArjunBhuptani commented 5 years ago

Is your feature request related to a problem? Please describe. Right now, there's no way to transfer to an offline counterparty. Supporting this will be pretty critical to even basic usage of v2.

Describe the solution you'd like I believe we can do this using a modified simplified version of the contract that already exists with Link transfers.

The main challenge here will be figuring out a way to get the secret to the recipient without leaking it to the hub. This would mean encrypting the secret and also setting up Nats queuing to make sure it gets to the counterparty.

bohendo commented 4 years ago

Flow proposed by @LayneHaber:

  1. User A wants to pay User B while B is offline (or without them explicitly being online)
  2. User A installs the linked transfer app with the hub, depositing the full payment amount
  3. User A creates a preImage and paymentId , encrypts it such that the hub cannot decrypt these values, and sends it to User B’s queue
  4. User B’s queue is stored on a NATS server hosted by the hub, so the encryption is an important step
  5. User B comes back online, queries their queue, and decrypts the information from User A
  6. User B installs the linked app with the hub and reveals the secrets in takeAction
  7. Hub pays the user, and uses the decrypted secrets to reclaim its funds with the sender
ArjunBhuptani commented 4 years ago

This is now a meta-issue of the following:

rhlsthrm commented 4 years ago

For the first pass, we can probably do this:

  1. write app contract with recipient instead of payment ID
  2. add node install checks to make sure recipient matches before redeeming offline payment
  3. add DB configs for async payments to store them with status in {pending, redeemed, failed}
  4. add node NATS subject to retrieve all pending async payments
  5. add client method for endpoint, have client retrieve and complete all async payments when it comes online
rhlsthrm commented 4 years ago

Got send portion of async transfer working, figured out encrypt/decrypt stuff, still need to wrap up redeem.

ArjunBhuptani commented 4 years ago

Closed via https://github.com/ConnextProject/indra/pull/403