gabstv / go-monero

A Monero RPC Wallet client implementation written in Go (Golang)
MIT License
60 stars 22 forks source link

type []walletrpc.Payment has no field or method #7

Closed yume-red closed 3 years ago

yume-red commented 3 years ago

The following program doens't work

package main

import (
        "fmt"

        "github.com/gabstv/go-monero/walletrpc"
)
/*
type Payment struct {
    PaymentID   string
    TxHash      string
    Amount      uint64
    BlockHeight uint64
    UnlockTime  uint64
}
*/

func main() {
        client := walletrpc.New(walletrpc.Config{
                Address: "http://127.0.0.1:18085/json_rpc",})

        var check []walletrpc.Payment

        check, _ = client.GetPayments("0000000000000000")

        fmt.Println(check.Amount)
}

Error message: ./main.go:18:19: check.Amount undefined (type []walletrpc.Payment has no field or method Amount)

Link to the Payment type: https://pkg.go.dev/github.com/gabstv/go-monero/walletrpc#Payment I have tried to grab the other variables in this type with the same issue.

yume-red commented 3 years ago

Sorry didn't realise it was a list. fmt.Println(check[0].Amount) works