go-salvium

module
v0.0.0-...-90a112d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2025 License: Apache-2.0

README

go-salvium

GoDoc

A multi-platform Go library for interacting with Salvium nodes either on clearnet or not, supporting daemon and wallet RPC, p2p commands and ZeroMQ.

Quick start

Library

To consume go-salvium as a library for your Go project:

go get -u -v github.com/mxhess/go-salvium

go-salvium exposes an high-level package: rpc.

The package rpc, is used to communicate with salviumd and salvium-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, )

rpc itself is subdivided in two other packages: wallet and daemon, exposing salvium-wallet-rpc and salviumd RPCs accordingly.

For instance, to get the the height of the main chain:

package daemon_test

import (
	"context"
	"fmt"

	"github.com/mxhess/go-salvium/rpc"
	"github.com/mxhess/go-salvium/rpc/daemon"
)

func ExampleGetHeight() {
	ctx := context.Background()
	addr := "http://localhost:19081"

	// 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 salvium-wallet-rpc:

package wallet_test

import (
	"context"
	"fmt"

	"github.com/mxhess/go-salvium/rpc"
	"github.com/mxhess/go-salvium/rpc/wallet"
)

func ExampleGetHeight() {
	ctx := context.Background()
	addr := "http://localhost:19082"

	// 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.

Thanks

Huge thanks to Ciro Costa for writing the original implementation and duggavo for their improvements!

Directories

Path Synopsis
This is a derived work based on `code.google.com/p/mlab-ns2/gae/ns/digest` (original work of Bipasa Chattopadhyay bipasa@cs.unc.edu Eric Gavaletz gavaletz@gmail.com Seon-Wook Park seon.wook@swook.net, from the fork maintained by Bob Ziuchkovski @bobziuchkovski (https://github.com/rkl-/digest).
This is a derived work based on `code.google.com/p/mlab-ns2/gae/ns/digest` (original work of Bipasa Chattopadhyay bipasa@cs.unc.edu Eric Gavaletz gavaletz@gmail.com Seon-Wook Park seon.wook@swook.net, from the fork maintained by Bob Ziuchkovski @bobziuchkovski (https://github.com/rkl-/digest).
rpc
Package rpc provides a client that's able to communicate with a `monerod` daemon via its RPC interfaces.
Package rpc provides a client that's able to communicate with a `monerod` daemon via its RPC interfaces.
daemon
Package daemon provides a client that encapsulates RPC methods and endpoints that can be hit in a daemon.
Package daemon provides a client that encapsulates RPC methods and endpoints that can be hit in a daemon.
wallet
Package wallet provides a client that encapsulates RPC methods that can be hit in a wallet rpc server.
Package wallet provides a client that encapsulates RPC methods that can be hit in a wallet rpc server.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL