2

I need to check if an account trustline is authorized or not (before payment)

Eg: this account https://horizon-testnet.stellar.org/accounts/GDT43XDX4VP7JPJUXRZO7JJH4PHJRCXYFPJA5PJPQC4MLLTF6PEEY5JU has COP but the trustline has authorized flag set to false.

thanks in advance

3

The operations-for-account endpoint will list all operations for that specific account incl. changes to the trustlines.

If you scroll to the bottom on this stellar laboratory page (after clicking submit) it will show you the following operation which changed the authorize flag to false:

  {
    [...]
    "id": "41852832801886209",
    "paging_token": "41852832801886209",
    "source_account": "GDT37ZBADDLUNLEESWXEGZVGIZXQEDI6FHEBMUFGLHGPI3VIDD3DGNZP",
    "type": "allow_trust",
    "type_i": 7,
    "created_at": "2018-06-29T01:35:13Z",
    "transaction_hash": "1405516165b1e39b108cadd1c0c3b09baaea8edd9d536a1b679cca510e52b549",
    "asset_type": "credit_alphanum4",
    "asset_code": "COP",
    "asset_issuer": "GDT37ZBADDLUNLEESWXEGZVGIZXQEDI6FHEBMUFGLHGPI3VIDD3DGNZP",
    "trustee": "GDT37ZBADDLUNLEESWXEGZVGIZXQEDI6FHEBMUFGLHGPI3VIDD3DGNZP",
    "trustor": "GDT43XDX4VP7JPJUXRZO7JJH4PHJRCXYFPJA5PJPQC4MLLTF6PEEY5JU",
    "authorize": false
  }

I'm not aware of an easier way to find this information at the moment. There is an open issue to simplify this.

  • balances object under GET /accounts/:id now has a is_authorized to validate if trustline exists (source - same issue link mentioned in the answer) – Ashwani Agarwal Sep 23 at 9:45
0

Use stellar.expert as that is quite easy in interface. If an account has created trustline, it will show balance 0 for that asset in the explorer.

  • thanks but I need a way using horizon not external tools – dolcalmi Jul 1 '18 at 19:11
  • 1
    You can also do it using horizon, basically check if asset_code is true and asset_type is not native than that account has COP(asset) trustline. Authorized flag is a setting, with which the anchor must approve anyone who wants to hold its asset, allowing it to control who its customers are. – Peter Jul 1 '18 at 19:50
  • thanks but for eg.. this account horizon-testnet.stellar.org/accounts/… will return true with that validation but authorized flag is false and cant do transactions with COP – dolcalmi Jul 2 '18 at 20:52
  • That does not show the required flag. – shredding Aug 16 '18 at 9:24
0

I hacked my way around it by logging the accounts to which I send an AllowTrust operation. When sending payments, I always do the AllowTrust however I skip the accounts I logged in my CSV file.

Note: This is not a best practice. I'm a big fan of including an authorized boolean in the balances array of the output.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.