Go Monero RPC Client
A client implementation for the Monero wallet and daemon RPC written in go.
This package is inspired by https://github.com/gabstv/go-monero.
Wallet RPC Client

Monero RPC Version
The go-monero-rpc-client/wallet
package is the RPC client for version v1.3
of the Monero Wallet RPC.
Installation
go get -u github.com/chekist32/go-monero-rpc-client
Spawn the monero-wallet-rpc daemon (without rpc login):
./monero-wallet-rpc --wallet-file /home/$user/stagenetwallet/stagenetwallet --daemon-address pool.cloudissh.com:38081 --stagenet --rpc-bind-port 6061 --password 'mystagenetwalletpassword' --disable-rpc-login
You can use our remote node for the stagenet running at pool.cloudissh.com port 38081
.
Go code:
package main
import (
"encoding/json"
"fmt"
"log"
"github.com/chekist32/go-monero-rpc-client/wallet"
)
func checkerr(err error) {
if err != nil {
log.Panic(err)
}
}
func main() {
// Start a wallet client instance
client := wallet.New(wallet.Config{
Address: "http://127.0.0.1:6061/json_rpc",
})
// check wallet balance
resp, err := client.GetBalance(&wallet.RequestGetBalance{AccountIndex: 0})
checkerr(err)
res, _ := json.MarshalIndent(resp, "", "\t")
fmt.Print(string(res))
// get incoming transfers
resp1, err := client.GetTransfers(&wallet.RequestGetTransfers{
AccountIndex: 0,
In: true,
})
checkerr(err)
for _, in := range resp1.In {
res, _ := json.MarshalIndent(in, "", "\t")
fmt.Print(string(res))
}
}
Spawn the monero-wallet-rpc daemon (with rpc login):
./monero-wallet-rpc --wallet-file /home/$user/stagenetwallet/stagenetwallet --daemon-address pool.cloudissh.com:38081 --stagenet --rpc-bind-port 6061 --password 'mystagenetwalletpassword' --rpc-login test:testpass
Go code:
package main
import (
"encoding/json"
"fmt"
"log"
"github.com/chekist32/go-monero-rpc-client/wallet"
)
func checkerr(err error) {
if err != nil {
log.Panic(err)
}
}
func main() {
t := httpdigest.New("test", "testpass")
// Start a wallet client instance
client := wallet.New(wallet.Config{
Address: "http://127.0.0.1:6061/json_rpc",
Transport: t,
})
// check wallet balance
resp, err := client.GetBalance(&wallet.RequestGetBalance{AccountIndex: 0})
checkerr(err)
res, _ := json.MarshalIndent(resp, "", "\t")
fmt.Print(string(res))
// get incoming transfers
resp1, err := client.GetTransfers(&wallet.RequestGetTransfers{
AccountIndex: 0,
In: true,
})
checkerr(err)
for _, in := range resp1.In {
res, _ := json.MarshalIndent(in, "", "\t")
fmt.Print(string(res))
}
}
Daemon RPC Client
As of now, Monero daemon RPC client is not fully implemented. List of implemented methods.
LICENSE
MIT License