Go: Display trust line authorization state in the balances list

Created on 15 Nov 2017  路  16Comments  路  Source: stellar/go

Since this feature is used by more users recently it would be great to access it in Horizon. Seems to be very easy to implement.

Desired change to the JSON. Add a new array that is present if there are any unauthorized trustlines:

...,
"balances": [
    {
      "balance": "10.0000000",
      "limit": "922337203685.4775807",
      "asset_type": "credit_alphanum12",
      "asset_code": "DUBUNDA",
      "asset_issuer": "GCGTJPNBL7TNUO647AWQFEEL2PHK4BJ56RZCT77H2R6AHPCUC7CCHHGV"
    },
    {
      "balance": "9999.9999900",
      "asset_type": "native"
    }
  ],
"unauthorized_balances":[
 {
      "balance": "0.0000000",
      "limit": "922337203685.4775807",
      "asset_type": "credit_alphanum4",
      "asset_code": "USD",
      "asset_issuer": "GCGTJPNBL7TNUO647AWQFEEL2PHK4BJ56RZCT77H2R6AHPCUC7CCHHGV"
    },
],
...

help wanted horizon

All 16 comments

@bartekn,
can I take it?

I see Jed added "help wanted" tag so I think you can give it a try :). Let me know if you need any help.

@r8d8 I am going to sync my own horizon instance with the testnet in order to look at the trustlines table content, from the code there is no feeling that only authorized trustlines show up:

var selectTrustline = sq.Select(
    "tl.accountid",
    "tl.assettype",
    "tl.issuer",
    "tl.assetcode",
    "tl.tlimit",
    "tl.balance",
    "tl.flags",
).From("trustlines tl")

then

    // populate balances
    this.Balances = make([]Balance, len(ct)+1)
    for i, tl := range ct {
        err = this.Balances[i].Populate(ctx, tl)
        if err != nil {
            return
        }
    }

@bartekn,
can you please specify how this authorization state should be presented.
If I got it right, here is request to db that returns info for account, and then API callback for account info

Related to stellar/horizon#298

@r8d8 Thanks, haven't noticed this. Let's track it in https://github.com/stellar/horizon/issues/298

other way. let's close the other issue and track this here.

@nullstyle In the returned JSON from /accounts, would you be ok with another array called "unauthorized_balances" or something that lists the trustlines that still need go be auth'd by the issuer? It seemed like originally you wanted a separate endpoint to get the unauthorized trustlines of an account but maybe just clearly separating them out would be enough?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tomerweller picture tomerweller  路  4Comments

kr picture kr  路  5Comments

orbitlens picture orbitlens  路  6Comments

ire-and-curses picture ire-and-curses  路  6Comments

abuiles picture abuiles  路  6Comments