Merging account with trustlines

Open
#324 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Domain
blockchain

Research direction

Start by reviewing the accountMerge, payment, and change trust operations described in the issue, then read the comment thread for discussion of the two proposed solutions. Done would require a settled protocol design for handling non-native trustline assets during account merging, rather than an isolated code change.

Written by the indexing model from the issue text.

Description

CAP help wanted needs draft

In order to merge an account that has a trustline first the following operations need to be executed:

  • a payment operation that transfers the remaining balance of the trusted asset to some other account
  • a change trust operation to remove the trustline

Certain smart contract schemes (such as payment channels) involve refund transactions for escrow accounts that are created and signed well before they are submitted on chain. If such a scheme deals with an assets different from the native asset, then these refund transactions need to contain the following operations (as stated above):

  • a payment operation to clear the balance of that asset
  • remove the trustline of that asset
  • merge account

The refund transaction will fail if the payment operation does not contain the correct balance of the trusted asset at the time the transaction is submitted. Since the refund transaction is created and signed a long time before, this would allow an attacker to invalidate the transaction by sending a single stroop of the trusted asset to the escrow account before the refund transaction is submitted.

A workaround would be to always set the trust limit of the asset to the current balance on the account. However, this has some downsides – e.g., topping up a payment channel would not be possible.

We propose any of the following solutions:

  1. Extend the accountMerge operation: if the account to be merged has trustlines and the account to be merged into has the same trustlines, then merge all assets into the latter account.
  2. Add a "merge asset" operation that behaves like a payment operation but does not specify an amount – it will transfer the complete remaining amount of the specified asset on the source account instead.
Dominant language
RPC
Stars
632
Forks
399
Avg merge
1d 23h
Merged PRs (30d)
6

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from stellar/stellar-protocol

All issues in stellar/stellar-protocol

Similar issues

More Blockchain issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.