https://github.com/omani/go-monero-rpc-client
A go client for the Monero wallet and daemon RPC
https://github.com/omani/go-monero-rpc-client
daemon monero rpc wallet
Last synced: 16 days ago
JSON representation
A go client for the Monero wallet and daemon RPC
- Host: GitHub
- URL: https://github.com/omani/go-monero-rpc-client
- Owner: omani
- License: mit
- Created: 2019-05-09T23:36:20.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2025-02-08T02:33:33.000Z (3 months ago)
- Last Synced: 2025-04-02T11:05:06.881Z (23 days ago)
- Topics: daemon, monero, rpc, wallet
- Language: Go
- Homepage:
- Size: 389 KB
- Stars: 59
- Watchers: 2
- Forks: 18
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-monero - go-monero-rpc-client - A go client for the Monero wallet and daemon RPC (Libraries / Other Wallets)
README
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
[](https://godoc.org/github.com/omani/go-monero-rpc-client/wallet)
### Monero RPC Version
The ```go-monero-rpc-client/wallet``` package is the RPC client for version `v1.3` of the [Monero Wallet RPC](https://www.getmonero.org/resources/developer-guides/wallet-rpc.html).### Installation
```sh
go get -u github.com/omani/go-monero-rpc-client
```#### Spawn the monero-wallet-rpc daemon (without rpc login):
```sh
./monero-wallet-rpc --wallet-file /home/$user/stagenetwallet/stagenetwallet --daemon-address YOUR_STAGENET_NODE:38081 --stagenet --rpc-bind-port 6061 --password 'mystagenetwalletpassword' --disable-rpc-login
```
You can either run your own stagenet server for testing purposes or select a remote stagenet node from eg. https://monero.fail/?chain=monero&network=stagenet (not associated with this site. I found it on google).#### Go code:
```Go
package mainimport (
"encoding/json"
"fmt"
"log""github.com/omani/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):
```sh
./monero-wallet-rpc --wallet-file /home/$user/stagenetwallet/stagenetwallet --daemon-address YOUR_STAGENET_NODE:38081 --stagenet --rpc-bind-port 6061 --password 'mystagenetwalletpassword' --rpc-login test:testpass
```#### Go code:
```Go
package mainimport (
"encoding/json"
"fmt"
"log""github.com/omani/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, only the wallet RPC has been implemented.
# Contribution
* You can fork this, extend it and contribute back.
* You can contribute with pull requests.# Donations
You can make me happy by donating Bitcoin to the following address:
```
bc1qgezvfp4s0xme8pdv6aaqu9ayfgnv4mejdlv3tx
```# LICENSE
MIT License