Skip to content

setupAccount's implementation differs from the spec #15

Description

@georgeroman

The implementation of the setupAccount action differs from the official specification (https://github.com/interledger/rfcs/blob/master/0038-settlement-engines/0038-settlement-engines.md#setup-an-account). Here are the differences:

  • the specification doesn't say anything about passing an empty settlement account id, but here an account id is automatically generated if none is passed
  • the specification doesn't say anything about returning the settlement account id back to the connector (it only requires a 201 status code in case of success), but here the account id is returned as well (of course, this is to make the connector aware of the settlement account id generated by the settlement engine)

I'm not sure which is the correct way to implement the setup account action. It looks like interledger-rs works fine with following the official specs but ilpv4-connector doesn't and requires the extra steps.

Here is the setupAccount implementation:

setupAccount: async (req, res) => {
const accountId = req.body.id || uuid() // Create account ID if none was provided
if (!isSafeKey(accountId)) {
return res.status(400).send('Account ID includes unsafe characters')
}
/**
* TODO
* Before creating the accout/calling setup, ensure the peer is reachable:
* Try pinging them and await either a response or a ping from said peer
*/
try {
await store.createAccount(accountId)
} catch (err) {
log(`Failed to setup account: account=${accountId}`, err)
return res.sendStatus(500)
}
if (engine.setupAccount) {
try {
await engine.setupAccount(accountId) // TODO Is it safe if this is called multiple times?
} catch (err) {
log(`Failed to setup account: account=${accountId}`, err)
return res.sendStatus(500)
}
}
res.status(201).send({
id: accountId
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions