Roadrunner
Roadrunner

Reputation: 11

why aren't trustlines removed and reserve unlocked on xrpl

I am new to the xrpl and working through the python tutorials. yesterday I got to set up three trustlines and today I tried without success to delete them.

In my online research I found these two threads in the xrpchat website:

https://www.xrpchat.com/topic/2338-how-to-totally-remove-trustlines/

https://www.xrpchat.com/topic/16834-is-there-a-way-to-totally-remove-trust-lines/

Both of threads provide the same answer:

If a trustline is in its default state on your side, it will not be counted against your reserve. If a trustline is in its default state on both sides, it will be removed. Default state means:

  1. Balance is zero.
  2. Limit is zero.
  3. Line is not authed or frozen.
  4. Line does not allow rippling, unless account has "DefaultRipple" flag set, in which case it must allow rippling.

imo the three trustlines I am triing to remove fulfil the four mentioned points... The trasactions finished successfully "Trustline removed" but the trustlines are still being showed and the reserve for them locked (see screen shot from https://test.bithomp.com/).

I can not figure out what I am missing or doing wrong. So I would really appreciate, if someone could point out what is my mistake and how to solve it.

[enter image description here][1]

This is the address I am using: rf84on2iJ41Dy67M6ZdMCJzBA9rVZynos4

these are the three trustlines I created:


token_currency_code = "ZAP"

token_issuer = "rpswrb1mVCtahne4R2NHGe1eTemwAg3Y7X"

token_value = "47.61678015"


token_currency_code = "WAN"

token_issuer = "rpswrb1mVCtahne4R2NHGe1eTemwAg3Y7X"

token_value = "1.17096019"


token_currency_code = "MXN"

token_issuer = "rpswrb1mVCtahne4R2NHGe1eTemwAg3Y7X"

token_value = "17.8441"


when deleting I used:


token_currency_code = "ZAP"

token_issuer = "rpswrb1mVCtahne4R2NHGe1eTemwAg3Y7X"

token_value = "0"


token_currency_code = "WAN"

token_issuer = "rpswrb1mVCtahne4R2NHGe1eTemwAg3Y7X"

token_value = "0"


token_currency_code = "MXN"

token_issuer = "rpswrb1mVCtahne4R2NHGe1eTemwAg3Y7X"

token_value = "0"


I have being playing around with these flags without results

flags= 262144, # Disable the No Ripple flag, allowing rippling on this trust line. flags= 131072, # Enable the No Ripple flag flags= 1048576, # Freeze the trust line.

This is the code I have been using:

client = JsonRpcClient(JSON_RPC_URL)

My_Wallet_Address = "rf84on2iJ41Dy67M6ZdMCJzBA9rVZynos4"
My_Wallet_seed = "<myseed>"

#    flags= 262144, # Disable the No Ripple flag, allowing rippling on this trust line.
#    flags= 131072, # Enable the No Ripple flag
#    flags= 1048576, # Freeze the trust line.
tx_flags= 1048576

# -----------------
token_currency_code = "ZAP"
token_issuer = "rpswrb1mVCtahne4R2NHGe1eTemwAg3Y7X"
token_value = "0"
# -----------------
#token_currency_code = "WAN"
#token_issuer = "rpswrb1mVCtahne4R2NHGe1eTemwAg3Y7X"
#token_value = "0"
# -----------------
#token_currency_code = "MXN"
#token_issuer = "rpswrb1mVCtahne4R2NHGe1eTemwAg3Y7X"
#token_value = "0"
# ------------------

from xrpl.core import keypairs
public, private = keypairs.derive_keypair(My_Wallet_seed)
My_Wallet_account = keypairs.derive_classic_address(public)

from xrpl.wallet import Wallet
My_Wallet_wallet: Wallet = xrpl.wallet.Wallet(My_Wallet_seed, 0)

from xrpl.ledger import get_fee
# Delete trust line  -----------------------------------
trust_set_tx = xrpl.models.transactions.TrustSet(
    account=My_Wallet_wallet.classic_address,
    fee=get_fee(client),
    flags= tx_flags,
    limit_amount=xrpl.models.amounts.issued_currency_amount.IssuedCurrencyAmount(
        currency=token_currency_code,
        issuer=token_issuer,
        value=token_value,
    )
)

ts_prepared = xrpl.transaction.safe_sign_and_autofill_transaction(
    transaction=trust_set_tx,
    wallet=My_Wallet_wallet,
    client=client,
)
print("Delete trust line ...")
response = xrpl.transaction.send_reliable_submission(ts_prepared, client)
print(response)
``


and this is the output:
Delete trust line ...
Response(status=<ResponseStatus.SUCCESS: 'success'>, result={'Account': 'rf84on2iJ41Dy67M6ZdMCJzBA9rVZynos4', 'Fee': '10', 'Flags': 1048576, 'LastLedgerSequence': 24145712, 'LimitAmount': {'currency': 'ZAP', 'issuer': 'rpswrb1mVCtahne4R2NHGe1eTemwAg3Y7X', 'value': '0'}, 'Sequence': 24095419, 'SigningPubKey': 'ED6D46333BBAB91D539FEA52E1129FAB0F52DCA72BD681F5952B0C408D27A4C9F1', 'TransactionType': 'TrustSet', 'TxnSignature': '12653F1536ABB39346F8172A2B1DAC6D1FEA17C1AA12212C845134A937FE74CDC91224F880C4010B487D073F756F736904819E33DE4CF284DF2E8EF7C675B30A', 'date': 694613911, 'hash': '0ED99BDB7A1D6D44AE519407C9154BCC80DA448AF0C1D4B56473383D7DB4DCA4', 'inLedger': 24145695, 'ledger_index': 24145695, 'meta': {'AffectedNodes': [{'ModifiedNode': {'FinalFields': {'Account': 'rf84on2iJ41Dy67M6ZdMCJzBA9rVZynos4', 'Balance': '21999840', 'Flags': 0, 'OwnerCount': 3, 'Sequence': 24095420}, 'LedgerEntryType': 'AccountRoot', 'LedgerIndex': 'B4F90BF9B121813B822C4473F30E5CCCC4BE798E74CD55C0B15A77E644BE7D9C', 'PreviousFields': {'Balance': '21999850', 'Sequence': 24095419}, 'PreviousTxnID': '2458A55EBDCD918E8C067305B93D3FDD56824EC26608FD475F3A6E25115F9E67', 'PreviousTxnLgrSeq': 24124624}}], 'TransactionIndex': 0, 'TransactionResult': 'tesSUCCESS'}, 'validated': True}, id=None, type=<ResponseType.RESPONSE: 'response'>)
``
Any Idea, what my mistake is?

Many thanks in advance.

  [1]: https://i.sstatic.net/vusZe.png

Upvotes: 1

Views: 685

Answers (1)

mDuo13
mDuo13

Reputation: 136

You're on the right track, and the points you listed are the right ones. It can be tricky to figure out which of those points a trust line doesn't match, but the way I do it is to make an account_lines call and look at the fields of the result.

In the case of your ZAP line, here's what it shows:

{
    "account": "rpswrb1mVCtahne4R2NHGe1eTemwAg3Y7X",
    "balance": "0",
    "currency": "ZAP",
    "freeze": true,
    "limit": "0",
    "limit_peer": "0",
    "no_ripple": true,
    "no_ripple_peer": true,
    "quality_in": 0,
    "quality_out": 0
  }

You can see there that the limit, quality, and balance numbers are all zeroes, so that's set. The No Ripple settings on both sides are set to true which is probably the default, though I'd have to double-check both accounts' Default Ripple flags to be sure. But the freeze setting is set to true on your side, which is not the default. Looking at your code sample, that makes sense since your transactions have been setting tx_flags= 1048576 which is the "enable freeze" flag value. So, to get this line removed, you'll need to send a TrustSet to clear the freeze. The value for that is xrpl.models.transactions.TrustSetFlag.TF_CLEAR_FREEZE or 0x00200000. From what I can see, the other two trust lines are in the same state.

In short, your code sample should work great if you change just one line:

tx_flags=xrpl.models.transactions.TrustSetFlag.TF_CLEAR_FREEZE

(This is assuming you've done import xrpl. Of course, you can do your imports differently or just use the raw value 2097152.)

Anyway, after running the code again with this change, you should see that the trust lines got removed, which you can verify with an explorer or with the WebSocket API tool using the same example account_lines call I linked way back at the beginning.

Upvotes: 2

Related Questions