getHeight gets the current blockchain height using raw JSON
(rpcURL string)
| 234 | |
| 235 | // getHeight gets the current blockchain height using raw JSON |
| 236 | func getHeight(rpcURL string) (uint64, error) { |
| 237 | respBody, err := postRawJSON(rpcURL+"/v1/query/height", "{}") |
| 238 | if err != nil { |
| 239 | return 0, err |
| 240 | } |
| 241 | |
| 242 | var result struct { |
| 243 | Height uint64 `json:"height"` |
| 244 | } |
| 245 | if err := json.Unmarshal(respBody, &result); err != nil { |
| 246 | return 0, fmt.Errorf("failed to parse response: %v", err) |
| 247 | } |
| 248 | |
| 249 | return result.Height, nil |
| 250 | } |
| 251 | |
| 252 | // getAccountBalance gets the balance of an account using raw JSON |
| 253 | func getAccountBalance(rpcURL, address string) (uint64, error) { |
no test coverage detected