xrpl.js icon indicating copy to clipboard operation
xrpl.js copied to clipboard

Unable to delete account at some case: when clear trustlines before spent all tokens.

Open code-brewer opened this issue 2 years ago • 2 comments

I did some test to delete account that had been use to accept and spent token, and found in one case I was able to delete account after token transaction test, while in another case, I was unable to delete this account.

  1. First case: Get a account from faucet, then set some trustlines to tokens, receive tokens, spent tokens, clear trustlines by set limit to zero. Then call 'AccountDelete' for this account, it was deleted successfully.

Before go onto next test, I send some XRP this the deleted account to make it relived.

  1. Second case: Set some trustlines to tokens, receive tokens. And set trustlines to zero, spent all tokens. (Note here the order diff from first case ) Now, run 'AccountDelete' command failed, say XrplError: Account rueYXdp47Rnjg6DMTrhgXaunme3Qi2NXL cannot be deleted; there are Escrows, PayChannels, RippleStates, or Checks associated with the account. After that, I try clear trustline, set trustline, send some tokens, spend all, clear trustline, still unable to delete this account!

In second test case, the account_lines command shows are:

"result": { "account": "rueYXdp47Rnjg6DMTrhgXaunme3Qi2NXL", "ledger_current_index": 31200293, "lines": [ { "account": "rDqaV8aoWPSqPGdy6iXLYzqeA1DEGMCrzJ", "balance": "0", "currency": "Moo", "limit": "0", "limit_peer": "0", "no_ripple": false, "no_ripple_peer": false, "quality_in": 0, "quality_out": 0 }, { "account": "rDqaV8aoWPSqPGdy6iXLYzqeA1DEGMCrzJ", "balance": "0", "currency": "Bee", "limit": "0", "limit_peer": "0", "no_ripple": false, "no_ripple_peer": false, "quality_in": 0, "quality_out": 0 } ], "validated": false }, "type": "response" }

My test account: https://testnet.xrpl.org/accounts/rueYXdp47Rnjg6DMTrhgXaunme3Qi2NXL/transactions

I think it should allow me to delete my account since I have set all trustline to 0 and have zero balances.

From my test, it seem the order of spend tokens and clear trustline matter. But now, I was unable to make this account go back to correct state in order to delete it.

Any idea?

Any help will be appricated!

code-brewer avatar Sep 15 '22 16:09 code-brewer

There are still RippleStates linked to the account. As you can see here with account_objects deletion_blockers_only, there are a couple of deletion blockers:

{
  "result": {
    "account": "rueYXdp47Rnjg6DMTrhgXaunme3Qi2NXL",
    "account_objects": [
      {
        "Balance": {
          "currency": "Moo",
          "issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
          "value": "0"
        },
        "Flags": 65536,
        "HighLimit": {
          "currency": "Moo",
          "issuer": "rDqaV8aoWPSqPGdy6iXLYzqeA1DEGMCrzJ",
          "value": "0"
        },
        "HighNode": "1",
        "LedgerEntryType": "RippleState",
        "LowLimit": {
          "currency": "Moo",
          "issuer": "rueYXdp47Rnjg6DMTrhgXaunme3Qi2NXL",
          "value": "0"
        },
        "LowNode": "0",
        "PreviousTxnID": "892BB01EE9B30C89518F1E6515D602533889E6121A1C5398AB8DD2BB4281F01F",
        "PreviousTxnLgrSeq": 31199870,
        "index": "3E623689DE17911599994745D6F167B0BDB159A1D93A83C3770E1FEFBE1AFE39"
      },
      {
        "Balance": {
          "currency": "Bee",
          "issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
          "value": "0"
        },
        "Flags": 65536,
        "HighLimit": {
          "currency": "Bee",
          "issuer": "rDqaV8aoWPSqPGdy6iXLYzqeA1DEGMCrzJ",
          "value": "0"
        },
        "HighNode": "1",
        "LedgerEntryType": "RippleState",
        "LowLimit": {
          "currency": "Bee",
          "issuer": "rueYXdp47Rnjg6DMTrhgXaunme3Qi2NXL",
          "value": "0"
        },
        "LowNode": "0",
        "PreviousTxnID": "61E26DFD3445F5E2525AE467641E8668A442C16288F8987924D91DA9FE6CA998",
        "PreviousTxnLgrSeq": 31199872,
        "index": "7B671D9D1B49D53ECE23D542783C0D87EF3B40B6C54F08763EE85D9AEA9127E4"
      }
    ],
    "ledger_hash": "AD59FD900DB93E890DB638042AA59EC51D59DC54308372B44474238043838E4A",
    "ledger_index": 31201627,
    "validated": true
  },
  "status": "success",
  "type": "response"
}

Can you try to set the limits to 0 again?

If you reset a trust line to its default state (0 limit, 0 balance, and no non-default settings), it should get removed.

intelliot avatar Sep 15 '22 17:09 intelliot

I would also note it seems like the setting which may be non-default is probably the no_ripple setting on the trustline. Apparently that is normally true, but in your case it seems to be false.

Link to docs which say that: https://xrpl.org/trust-lines-and-issuing.html#trust-line-settings

JST5000 avatar Sep 15 '22 17:09 JST5000

Sorry for late response. The solution is to add 'tfSetNoRipple' to the Flags while do TrustSet .

    const  tx = {
        TransactionType: "TrustSet",
        Account: hot_wallet.address,
        LimitAmount: {
            "currency": tk_name,
            "issuer": tk_issuer,
            "value": tk_max_limit 
        }
    }

    tx.Flags = xrpl.TrustSetFlags.tfSetNoRipple;  // the key to solve this issue

code-brewer avatar Oct 20 '22 12:10 code-brewer