All Projects β†’ gabstv β†’ Go Monero

gabstv / Go Monero

Licence: mit
A Monero RPC Wallet client implementation written in Go (Golang)

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Go Monero

Xmrig
RandomX, CryptoNight, AstroBWT and Argon2 CPU/GPU miner
Stars: ✭ 6,372 (+15441.46%)
Mutual labels:  monero
Ethereum nvidia miner
πŸ’° USB flash drive ISO image for Ethereum, Zcash and Monero mining with NVIDIA graphics cards and Ubuntu GNU/Linux (headless)
Stars: ✭ 772 (+1782.93%)
Mutual labels:  monero
Vue Coin Hive
Start mining coins in your Vue projects in 1 second.
Stars: ✭ 14 (-65.85%)
Mutual labels:  monero
Deepminer
deepMiner webminer proxy (update for cryptoNight R)
Stars: ✭ 497 (+1112.2%)
Mutual labels:  monero
Monero
Monero: the secure, private, untraceable cryptocurrency
Stars: ✭ 6,503 (+15760.98%)
Mutual labels:  monero
Vital Development
Stars: ✭ 16 (-60.98%)
Mutual labels:  rpc-client
Coin Hive Stratum
use CoinHive's JavaScript miner on any stratum pool
Stars: ✭ 380 (+826.83%)
Mutual labels:  monero
Monero Gui Guide
Guide for the Monero GUI wallet
Stars: ✭ 36 (-12.2%)
Mutual labels:  monero
Multipoolminer
Monitors crypto mining pools in real-time in order to find the most profitable for your machine. Controls any miner that is available via command line.
Stars: ✭ 750 (+1729.27%)
Mutual labels:  monero
Monero Testnet Sandbox
Monero (XMR) testnet sandbox with 3 daemons and 3 wallets
Stars: ✭ 12 (-70.73%)
Mutual labels:  monero
Cpuminer Multi
Multi-algo CPUMiner & Reference Cryptonote Miner (JSON-RPC 2.0)
Stars: ✭ 499 (+1117.07%)
Mutual labels:  monero
Xmrig Nvidia
Monero (XMR) NVIDIA miner
Stars: ✭ 560 (+1265.85%)
Mutual labels:  monero
Coinhiveminer
Small UI for the https://coin-hive.com/ mining API
Stars: ✭ 24 (-41.46%)
Mutual labels:  monero
Xmr Miner
Web-based Cryptocurrency miner, built with Vue.js
Stars: ✭ 444 (+982.93%)
Mutual labels:  monero
Awesome Monero
Curated list of links of useful resources for the Monero crypto-currency
Stars: ✭ 15 (-63.41%)
Mutual labels:  monero
Monero Stratum
Solo mining stratum for Monero & AEON with built-in Web-UI
Stars: ✭ 438 (+968.29%)
Mutual labels:  monero
Porthos Go
A RPC over AMQP library for the Go programming language
Stars: ✭ 7 (-82.93%)
Mutual labels:  rpc-client
Cryptogoblin
CryptoNote CPU/GPU mining tool for Monero (XMR)
Stars: ✭ 39 (-4.88%)
Mutual labels:  monero
Loowy
Lua WAMP client
Stars: ✭ 28 (-31.71%)
Mutual labels:  rpc-client
Awesome Blockchain
⚑️Curated list of resources for the development and applications of blockchain.
Stars: ✭ 937 (+2185.37%)
Mutual labels:  monero

go-monero

This package is a hub of monero related tools for Go. At this time, only the Wallet RPC Client is available.

Go Report Card Build Status

Wallet RPC Client

GoDoc

The go-monero/walletrpc package is a RPC client with all the methods of the v0.11.0.0 release. It does support digest authentication, however I don't recommend using it alone (without https). If there is a need to split the RPC client and server into separate instances, you could put a proxy on the instance that contains the RPC server and check the authenticity of the requests using https + X-API-KEY headers between the proxy and this RPC client (there is an example about this implementation below)

Installation

go get -u github.com/gabstv/go-monero/walletrpc

Usage

The simplest way to use walletrpc is if you have both the server (monero-wallet-rpc) and the client on the same machine.

Running monero-wallet-rpc:

monero-wallet-rpc --testnet --wallet-file ~/testnet/mywallet.bin --rpc-bind-port 18082 --disable-rpc-login

Go:

package main

import (
	"fmt"
	"os"

	"github.com/gabstv/go-monero/walletrpc"
)

func main() {
	// Start a wallet client instance
	client := walletrpc.New(walletrpc.Config{
		Address: "http://127.0.0.1:18082/json_rpc",
	})

	// check wallet balance
	balance, unlocked, err := client.GetBalance()

	// there are two types of error that can happen:
	//   connection errors
	//   monero wallet errors
	// connection errors are pretty much unicorns if everything is on the
	// same instance (unless your OS hit an open files limit or something)
	if err != nil {
		if iswerr, werr := walletrpc.GetWalletError(err); iswerr {
			// it is a monero wallet error
			fmt.Printf("Wallet error (id:%v) %v\n", werr.Code, werr.Message)
			os.Exit(1)
		}
		fmt.Println("Error:", err.Error())
		os.Exit(1)
	}

	fmt.Println("Balance:", walletrpc.XMRToDecimal(balance))
	fmt.Println("Unlocked balance:", walletrpc.XMRToDecimal(unlocked))

	// Make a transfer
	res, err := client.Transfer(walletrpc.TransferRequest{
		Destinations: []walletrpc.Destination{
			{
				Address: "45eoXYNHC4LcL2Hh42T9FMPTmZHyDEwDbgfBEuNj3RZUek8A4og4KiCfVL6ZmvHBfCALnggWtHH7QHF8426yRayLQq7MLf5",
				Amount:  10000000000, // 0.01 XMR
			},
		},
		Priority: walletrpc.PriorityUnimportant,
		Mixin:    1,
	})
	if err != nil {
		if iswerr, werr := walletrpc.GetWalletError(err); iswerr {
			// insufficient funds return a monero wallet error
			// walletrpc.ErrGenericTransferError
			fmt.Printf("Wallet error (id:%v) %v\n", werr.Code, werr.Message)
			os.Exit(1)
		}
		fmt.Println("Error:", err.Error())
		os.Exit(1)
	}
	fmt.Println("Transfer success! Fee:", walletrpc.XMRToDecimal(res.Fee), "Hash:", res.TxHash)
}

Using Digest Authentication

monero-wallet-rpc --testnet --rpc-bind-ip 127.0.0.1 --rpc-bind-port 29567 --rpc-login john:doe --wallet-file ~/testnet/wallet_03.bin
package main

import (
	"fmt"

	"github.com/gabstv/go-monero/walletrpc"
	"github.com/gabstv/httpdigest"
)

func main() {
	// username: john
	// password: doe
	t := httpdigest.New("john", "doe")

	client := walletrpc.New(walletrpc.Config{
		Address:   "http://127.0.0.1:29567/json_rpc",
		Transport: t,
	})

	balance, unlocked, err := client.GetBalance()

	if err != nil {
		panic(err)
	}
	fmt.Println("balance", walletrpc.XMRToDecimal(balance))
	fmt.Println("unlocked balance", walletrpc.XMRToDecimal(unlocked))
}

Using a proxy

You can use a proxy to be in between this client and the monero RPC server. This way you can use a safe encryption tunnel around the network.

Starting the RPC server

monero-wallet-rpc --testnet --wallet-file ~/testnet/mywallet.bin --rpc-bind-port 18082 --disable-rpc-login

Starting a proxy server

This example uses sandpiper (github.com/gabstv/sandpiper/sandpiper) but you could also use nginx or apache

sandpiper config.yml:

debug: true
#listen_addr:     :8084
listen_addr_tls: :23456
fallback_domain: moneroproxy
routes:
  - 
    domain:        moneroproxy
    out_conn_type: HTTP
    out_addr:      localhost:18082
    auth_mode:  apikey
    auth_key:   X-API-KEY
    auth_value: 55c12fca1b994455d3ec1795bdc82cca
    tls_cert_file: moneroproxy.cert.pem
    tls_key_file:  moneroproxy.key.pem

The Go program is similar, but it uses an API-KEY:

package main

import (
	"fmt"
    "os"
    "net/http"
    "crypto/tls"

	"github.com/gabstv/go-monero/walletrpc"
)

func main() {
	// Start a wallet client instance
	client := walletrpc.New(walletrpc.Config{
        Address: "http://127.0.0.1:23456/json_rpc",
        CustomHeaders: map[string]string{
			"X-API-KEY": "55c12fca1b994455d3ec1795bdc82cca", // we use the same key defined above
        },
		Transport: &http.Transport{
			TLSClientConfig: &tls.Config{
				InsecureSkipVerify: true, // WARNING: instead of this, you can
				// provide (or install) a certificate to make it
				// really secure with Certificates: []tls.Certificate{},
			},
		},
	})

	// check wallet balance
	balance, unlocked, err := client.GetBalance()

	// there are two types of error that can happen:
	//   connection errors
	//   monero wallet errors
	// connection errors are pretty much unicorns if everything is on the
	// same instance (unless your OS hit an open files limit or something)
	if err != nil {
		if iswerr, werr := walletrpc.GetWalletError(err); iswerr {
			// it is a monero wallet error
			fmt.Printf("Wallet error (id:%v) %v\n", werr.Code, werr.Message)
			os.Exit(1)
		}
		fmt.Println("Error:", err.Error())
		os.Exit(1)
	}

	fmt.Println("Balance:", walletrpc.XMRToDecimal(balance))
    fmt.Println("Unlocked balance:", walletrpc.XMRToDecimal(unlocked))
}

Contributing

  • You can contribute with pull requests.
  • If could donate some XMR to the address below if you're feeling generous:
45eoXYNHC4LcL2Hh42T9FMPTmZHyDEwDbgfBEuNj3RZUek8A4og4KiCfVL6ZmvHBfCALnggWtHH7QHF8426yRayLQq7MLf5
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].