Skip to content

Goal remote node configΒ #2904

Closed
Closed
@barnjamin

Description

Problem

When getting started, goal is often the easiest method to start sending transactions. This ease is complicated by the need to have a node installed to get config/make requests.

Solution

Allow a config option for an Algod client that makes requests to a remote API.

@nullun pointed out that the algod.net file has the ip/port for a REST api. Pointing it to algoexplorerapi.io:443 worked to get node status on the cli after tweaking:

ben@LAPTOP-4EV1BSD6:~/go/src/github.com/algorand/go-algorand$ git diff
diff --git a/nodecontrol/algodControl.go b/nodecontrol/algodControl.go
index d6aed9f4..b180dfd4 100644
--- a/nodecontrol/algodControl.go
+++ b/nodecontrol/algodControl.go
@@ -86,7 +86,7 @@ func (nc NodeController) ServerURL() (url.URL, error) {
        if err != nil {
                return url.URL{}, err
        }
-       return url.URL{Scheme: "http", Host: addr}, nil
+       return url.URL{Scheme: "https", Host: addr}, nil
 }

 // GetHostAddress retrieves the REST address for the node from its algod.net file.
ben@LAPTOP-4EV1BSD6:~$ cat .algorand/algod.net
algoexplorerapi.io:443
ben@LAPTOP-4EV1BSD6:~$ goal node status
Last committed block: 16279285
Time since last block: 1.2s
Sync Time: 0.0s
Last consensus protocol: https://github.com/algorandfoundation/specs/tree/abc54f79f9ad679d2d22f0fb9909fb005c16f8a1
Next consensus protocol: https://github.com/algorandfoundation/specs/tree/abc54f79f9ad679d2d22f0fb9909fb005c16f8a1
Round for next consensus protocol: 16279286
Next consensus protocol supported: true
Last Catchpoint: 16270000#QK7RJHDC6FDDZ3QR4M5IDOSWXPD4XEQQP7ARI3EHKHVWRWOXMQQQ
Genesis ID: mainnet-v1.0
Genesis hash: wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=
ben@LAPTOP-4EV1BSD6:~$ goal asset info  --assetid 438831
Error processing command: json: cannot unmarshal array into Go struct field Account.assets of type map[uint64]v1.AssetHolding

It looks like the rest client has a number of the endpoints hardcoded to v1 endpoints/data structures

func (client RestClient) TransactionsByAddr(addr string, first, last, max uint64) (response v1.TransactionList, err error) {
err = client.get(&response, fmt.Sprintf("/v1/account/%s/transactions", addr), transactionsByAddrParams{first, last, max})
return
}
// PendingTransactionsByAddr returns all the pending transactions for a PK [addr].
func (client RestClient) PendingTransactionsByAddr(addr string, max uint64) (response v1.PendingTransactions, err error) {
err = client.get(&response, fmt.Sprintf("/v1/account/%s/transactions/pending", addr), pendingTransactionsByAddrParams{max})
return
}
// AssetInformation gets the AssetInformationResponse associated with the passed asset index
func (client RestClient) AssetInformation(index uint64) (response v1.AssetParams, err error) {
err = client.get(&response, fmt.Sprintf("/v1/asset/%d", index), nil)
return
}
// Assets gets up to max assets with maximum asset index assetIdx
func (client RestClient) Assets(assetIdx, max uint64) (response v1.AssetList, err error) {
err = client.get(&response, "/v1/assets", assetsParams{assetIdx, max})
return
}
// AssetInformationV2 gets the AssetInformationResponse associated with the passed asset index
func (client RestClient) AssetInformationV2(index uint64) (response generatedV2.Asset, err error) {
err = client.get(&response, fmt.Sprintf("/v2/assets/%d", index), nil)
return
}
// ApplicationInformation gets the ApplicationInformationResponse associated
// with the passed application index
func (client RestClient) ApplicationInformation(index uint64) (response generatedV2.Application, err error) {
err = client.get(&response, fmt.Sprintf("/v2/applications/%d", index), nil)
return
}
// AccountInformation also gets the AccountInformationResponse associated with the passed address
func (client RestClient) AccountInformation(address string) (response v1.Account, err error) {
err = client.get(&response, fmt.Sprintf("/v1/account/%s", address), nil)
return
}

I haven't tested all the endpoints yet.

Dependencies

goal, libgoal

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions