Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/duggavo/go-monero
Up-to-date Monero's P2P and RPC in Go
https://github.com/duggavo/go-monero
Last synced: 4 months ago
JSON representation
Up-to-date Monero's P2P and RPC in Go
- Host: GitHub
- URL: https://github.com/duggavo/go-monero
- Owner: duggavo
- License: apache-2.0
- Created: 2023-02-12T10:03:26.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2023-12-11T20:25:33.000Z (about 1 year ago)
- Last Synced: 2024-06-20T17:41:04.758Z (7 months ago)
- Language: Go
- Size: 142 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-monero - go-monero - A multi-platform Go library for interacting with Monero servers either on clearnet or not, supporting daemon and wallet RPC, p2p commands and ZeroMQ. (Libraries / Other Wallets)
README
# go-monero
[![GoDoc](https://img.shields.io/static/v1?label=godoc&message=reference&color=blue)](https://pkg.go.dev/github.com/duggavo/go-monero)
A multi-platform Go library for interacting with Monero servers
either on clearnet or not, supporting daemon and wallet RPC,
p2p commands and ZeroMQ.## Quick start
### Library
To consume `go-monero` as a library for your Go project:
```bash
go get -u -v github.com/duggavo/go-monero
````go-monero` exposes an high-level package: `rpc`.
The package `rpc`, is used to communicate with `monerod` and `monero-wallet-rpc` via its HTTP
endpoints. Note that not all endpoints/fields are exposed on a given port - if
it's being served in a restricted manner, you'll have access to less endpoints
than you see in the documentation
([daemon RPC](https://www.getmonero.org/resources/developer-guides/daemon-rpc.html), )`rpc` itself is subdivided in two other packages: `wallet` and `daemon`, exposing `monero-wallet-rpc` and `monerod` RPCs accordingly.
For instance, to get the the height of the main chain:
```go
package daemon_testimport (
"context"
"fmt""github.com/duggavo/go-monero/rpc"
"github.com/duggavo/go-monero/rpc/daemon"
)func ExampleGetHeight() {
ctx := context.Background()
addr := "http://localhost:18081"// instantiate a generic RPC client
client, err := rpc.NewClient(addr)
if err != nil {
panic(fmt.Errorf("new client for '%s': %w", addr, err))
}// instantiate a daemon-specific client and call the `get_height`
// remote procedure.
height, err := daemon.NewClient(client).GetHeight(ctx)
if err != nil {
panic(fmt.Errorf("get height: %w", err))
}fmt.Printf("height=%d hash=%s\n", height.Height, height.Hash)
}
```And to get the height from `monero-wallet-rpc`:
```go
package wallet_testimport (
"context"
"fmt""github.com/duggavo/go-monero/rpc"
"github.com/duggavo/go-monero/rpc/wallet"
)func ExampleGetHeight() {
ctx := context.Background()
addr := "http://localhost:18086"// instantiate a generic RPC client
client, err := rpc.NewClient(addr)
if err != nil {
panic(fmt.Errorf("new client for '%s': %w", addr, err))
}// instantiate a wallet-specific client and call the `get_height`
// remote procedure.
height, err := wallet.NewClient(client).GetHeight(ctx)
if err != nil {
panic(fmt.Errorf("get height: %w", err))
}fmt.Printf("height=%d\n", height.Height)
}
```## License
See [LICENSE](./LICENSE).
## Thanks
Huge thanks to [Ciro Costa](https://github.com/cirocosta/go-monero) for writing the original implementation!