XRPLF / xrpl-dev-portal

Source code for xrpl.org including developer documentation
https://xrpl.org
Other
541 stars 1.02k forks source link

Tutorial: remove a trust line #1239

Open mDuo13 opened 3 years ago

mDuo13 commented 3 years ago

Removing a trust line can be very tricky. A tutorial could help demonstrate all the steps that might be needed to remove a trust line or at least make it so that you don't owe the owner reserve for it. Basically:

  1. Check to see who owes a reserve on the RippleState object (you, the other account, or both)—this involves determining which accounts are high/low and then reading the flags.
    • It's possible that you don't owe a reserve and the other side does. If that's the case, you can't remove the object from the ledger, but you don't owe a reserve so you don't need to do anything else.
    • The object should be deleted when neither side owes a reserve.
    • It's possible that both sides owe a reserve.
  2. Identify which settings are in a non-default state.. The account_lines method should be helpful here, but you may need to look up the
    • To figure out if one party's "No Ripple" setting is in its default state, you have to check if that party's account has the Default Ripple flag set. The trust line's default "No Ripple" flag value is the opposite of whatever the account's "Default Ripple" flag is set to.
  3. Send transaction(s) to put the settings in their default state
    • If you hold a balance on the trust line, you have to zero it out. You could do this by sending a Payment back to the sender or by sending an OfferCreate to trade the token away. (It has to send/trade the entire balance to zero out the line, of course.)
    • If any of your settings on the trust line are non-default, you have to fix them with a TrustSet transaction. This includes:
      • If your trust limit is nonzero, you have to set it to 0. (Set value in the LimitAmount to 0)
      • If your QualityIn/QualityOut settings are non-default you have to set them to the default (0 or 1 billion, same thing in this case)
      • If you have an individual freeze on this trust line, you have to disable it (add the tfClearFreeze flag)
      • If your No Ripple setting is non-default, you have to set it to the default (using tfSetNoRipple or tfClearNoRipple depending on what your account's Default Ripple is set to)
      • (Remember: if you're using multiple flags you have to use bitwise-OR to combine them)

Stretch goals: interactivity. Making this interactive could be a bit challenging since the point of the doc is to help people figure out which of many possible starting conditions the line is in. Maybe there's a randomized or customizeable setup step at the beginning.

scottschurr commented 3 years ago

@mDuo13, or whoever addresses this, please think about how the XRP Ledger could be changed so removing a trust line is not so painful. For example, is there something we could add to TrustSet that would make it less painful to remove a trust line? Whatever thoughts you have would be really useful. Thanks.