Skip to content

accounts: extend update command functionality #648

Closed
@ViktorTigerstrom

Description

@ViktorTigerstrom

Is your feature request related to a problem? Please describe.

The functionality of the update command is that the command takes a id for an account, and then allows you to specify certain properties of the account to overwrite the account property value with.

One of the properties the command accepts, it to overwrite the account_balance with a specified value. This command will usually be used if you'd like to for example increase the account balance by 100k sats or similar.

However, using the command that way, is quite dangerous as the normal user flow would be as follows:

  1. You'd check what the current account balance is by using the info command. Say this command returns that the balance is currently 200k.
  2. You'd then sum the current balance with the amount you'd like to increase it with to get the new balance of the account, i.e.:
    200k+100k=300k
  3. You'd then run the update command to set the value to 300k.

Now the issue with this user flow, is that the the account user might have either received a payment to an invoice increasing the balance, or made a payment decreasing the balance, between step 1 and 3. Step 3 would then overwrite that account balance update. Say the accounts user makes a payment of 150k sats between step 1 and 3. The actual user account balance should be 150k after step 3, but will be 300k, meaning the account user profited 150k sats.

Another an issue we have, is that if a user receives an invoice update for a type of invoice we don't support (AMP invoices currently), or a payment that somehow errors, the entire account service will error be disabled for all accounts, and will be disabled even on next startup of litd when we try to process the invoice update or payment.

Describe the solution you'd like

It would be great if we could either update the update command, or make a new command to instead of overwriting the entire account balance, we'd have a command that either increases or decreases the user account balance by a certain amount, instead of setting the balance to a given amount. That way, any updates that happens between step 1 & 3 wouldn't be overwritten. I.e. the command would for example enable the node user to increase the user account balance by 100k, instead of actually setting it to exactly 300k.

To solve the issue of invoices and payments that make the account service crash, it would be great if the command would allow the node runner to deassociate a certain invoice or payment for a certain account id. That way, the account service would be able to run successfully on next startup.

Describe alternatives you've considered

Additional context

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions