Change project name

This commit is contained in:
DataHoarder 2022-10-05 09:40:23 +02:00
parent 0c66c0fe65
commit b6ca970f30
Signed by: DataHoarder
SSH key fingerprint: SHA256:OLTRf6Fl87G52SiR7sWLGNzlJt4WOX+tfI2yxo0z7xk
63 changed files with 162 additions and 508 deletions

View file

@ -50,7 +50,7 @@ linters:
linters-settings:
goimports:
local-prefixes: github.com/cirocosta/go-monero
local-prefixes: git.gammaspectra.live/P2Pool/go-monero
exhaustive:
default-signifies-exhaustive: true

View file

@ -6,8 +6,8 @@ If you already have [Go] installed, you can use to Go toolchain to build from
source and install it for you (under `$GOPATH/bin`):
```console
$ GO111MODULE=on go get github.com/cirocosta/go-monero/cmd/monero
go: downloading github.com/cirocosta/go-monero v0.0.3
$ GO111MODULE=on go get git.gammaspectra.live/P2Pool/go-monero/cmd/monero
go: downloading git.gammaspectra.live/P2Pool/go-monero v0.0.3
$ monero --help
Daemon, Wallet, and p2p command line monero CLI
@ -31,7 +31,7 @@ In the [releases page] you'll find the pre-compiled releases for each platform.
```bash
export VERSION=0.0.3
curl -SL -o- https://github.com/cirocosta/go-monero/releases/download/v$VERSION/go-monero_$VERSION_Linux_x86_64.tar.gz | \
curl -SL -o- https://git.gammaspectra.live/P2Pool/go-monero/releases/download/v$VERSION/go-monero_$VERSION_Linux_x86_64.tar.gz | \
tar xvzf monero
mv ./monero /usr/local/bin
```
@ -71,8 +71,8 @@ gpg: imported: 1
2. download the archive for your platform as well as the checksums
```console
$ curl -SOL https://github.com/cirocosta/go-monero/releases/download/v0.0.3/go-monero_0.0.3_Linux_x86_64.tar.gz
$ curl -SOL https://github.com/cirocosta/go-monero/releases/download/v0.0.3/checksums.txt.asc
$ curl -SOL https://git.gammaspectra.live/P2Pool/go-monero/releases/download/v0.0.3/go-monero_0.0.3_Linux_x86_64.tar.gz
$ curl -SOL https://git.gammaspectra.live/P2Pool/go-monero/releases/download/v0.0.3/checksums.txt.asc
```
@ -115,4 +115,4 @@ $ monero version
[Go]: https://golang.org/dl/
[releases page]: https://github.com/cirocosta/go-monero/releases
[releases page]: https://git.gammaspectra.live/P2Pool/go-monero/releases

326
README.md
View file

@ -1,336 +1,10 @@
# go-monero
[![GoDoc](https://img.shields.io/static/v1?label=godoc&message=reference&color=blue)](https://pkg.go.dev/github.com/cirocosta/go-monero)
A multi-platform [Go] library (and command line interface) for interacting with
[Monero] servers either on clearnet or not (see [Tor support]), supporting
daemon and wallet RPC, p2p commands and ZeroMQ.
## Quick start
### Command Line Interface
Under `cmd/monero` you'll find a command line interface that exposes most of
the functionality that the library provides.
You can either install it by using Go building from scratch
```console
$ GO111MODULE=on go get github.com/cirocosta/go-monero/cmd/monero
```
or, using [docker]
```console
$ docker run utxobr/go-monero:v0.0.5 --help
Daemon, Wallet, and p2p command line monero CLI
Usage:
monero [command]
Available Commands:
daemon execute remote procedure calls against a monero node
p2p execute p2p commands against a monero node
wallet execute remote procedure calls against a monero wallet rpc server
...
```
or fetching the binary for your distribution from the [releases page]. See
[INSTALL.md] for details and examples.
### Example
```console
$ monero daemon get-transaction --txn 53c1ef0cff73d12294e3055400826905efc397814aacd7208921a9abfd1f6328
Hash: 53c1ef0cff73d12294e3055400826905efc397814aacd7208921a9abfd1f6328
Fee (µɱ): 9.13
Fee per kB (µɱ): 6.416691832532602
In/Out: 1/2
Size: 1.4 KiB
Public Key: fbc0ac2c62514f68134f543ce5c4efe51ec55a0952eb188dadf22dccc3c5ffdf
Age: 20 minutes ago
Block: 2406735
Confirmations: 4
Outputs
STEALTH ADDR AMOUNT IDX
0 574e3a3dda7cde249a81c0a0637ce78999e114dd478479e3e04680ffdcd34c97 35307867
1 7d3e93ecfa2bd8c27f7a2bbd57488c1121924e58591b32e99be42da6ae249e9c 35307868
Input Key Image: 2cd588cbc9214e1b683a8c3f0d7c25b8e61779806051356dee1fac6cf42c0c7e
RING MEMBER TXID BLK AGE
0 ef729a26d047508fb1 1ed88a49d533e 2342514 2 months ago
1 33351ad5aed5df1c4b e0782b630670d 2382635 1 month ago
2 df5b27b873dc93e423 a96889571eab7 2397359 1 week ago
3 f30b7e8a36b38d95dc a3eede407f106 2401095 1 week ago
4 f684f88cd52ef0c39b de3a7e7b8ced8 2401120 1 week ago
5 96b6addb19dfa8ea78 13c9063f09e05 2402375 6 days ago
6 cd573966c650555377 4639ecf7293c8 2403122 5 days ago
7 b9c6c95c0994266249 04800ff34ee29 2404029 3 days ago
8 c4b4d2549c9a731157 6ebad604e6d81 2405504 1 day ago
9 36516e699ceffb665b e996d5b951ed1 2406458 9 hours ago
10 91ab8220d7d87e465f 9dd40e49611f1 2406541 6 hours ago
```
_(^ ring member and txid shortened just in this README for brevity sake)_
```console
$ monero --help
Daemon, Wallet, and p2p command line monero CLI
Usage:
monero [command]
Available Commands:
completion generate the autocompletion script for the specified shell
daemon execute remote procedure calls against a monero node
help Help about any command
p2p execute p2p commands against a monero node
wallet execute remote procedure calls against a monero wallet rpc server
Flags:
-h, --help help for monero
Use "monero [command] --help" for more information about a command.
```
```console
$ monero daemon --help
execute remote procedure calls against a monero node
Usage:
monero daemon [command]
Available Commands:
generate-blocks generate blocks when in regtest mode
get-alternate-chains display alternative chains as seen by the node
get-bans all the nodes that have been banned by our node
get-block full block information by either block height or hash
get-block-count look up how many blocks are in the longest chain known to the node
get-block-header retrieve block(s) header(s) by hash
get-block-headers-range retrieve a range of block headers
get-block-template generate a block template for mining a new block
get-coinbase-tx-sum compute the coinbase amount and the fees amount for n last blocks starting at particular height
get-connections information about incoming and outgoing connections.
get-fee-estimate estimate fees in atomic units per kB
get-height node's current chain height
get-info general information about the node and the network
get-last-block-header header of the last block.
get-net-stats networking statistics.
get-outs output details
get-peer-list peers lists (white and gray)
get-public-nodes all known peers advertising as public nodes
get-transaction lookup a transaction, in the pool or not
get-transaction-pool information about valid transactions seen by the node but not yet mined into a block, including spent key image info for the txpool
get-transaction-pool-stats statistics about the transaction pool
get-version version of the monero daemon
hardfork-info information regarding hard fork voting and readiness.
mining-status information about this daemon's mining activity
on-get-block-hash find out block's hash by height
relay-tx relay a list of transaction ids
rpc-access-tracking statistics about rpc access
set-bans ban another nodes
start-mining start mining on the daemon
stop-mining stop mining on the daemon
sync-info daemon's chain synchronization info
zmq listen for zmq notifications
Flags:
-a, --address string full address of the monero node to reach out to [MONERO_ADDRESS] (default "http://localhost:18081")
-h, --help help for daemon
-p, --password string password to supply for rpc auth
--request-timeout duration max wait time until considering the request a failure (default 1m0s)
--shorten-addresses whether addresses should be shortened when displaying pretty results (default true)
--tls-ca-cert string certificate authority to load
--tls-client-cert string tls client certificate to use when connecting
--tls-client-key string tls client key to use when connecting
-k, --tls-skip-verify skip verification of certificate chain and host name
-u, --username string name of the user to use during rpc auth
-v, --verbose dump http requests and responses to stderr
Use "monero daemon [command] --help" for more information about a command.
```
### Tor support
Nodes reachable only through the Tor network (hidden services) or proxying
traffic through Tor to clearnet _is_ supported despite the lack of a specific
flag for specifying the proxy address.
For instance:
```console
$ export HTTP_PROXY="socks5://127.0.0.1:9050"
$ export MONERO_ADDR=http://rbpgdckle3h3vi4wwwrh75usqtoc5r3alohy7yyx57isynvay63nacyd.onion:18089
$ monero daemon --verbose -a $MONERO_ADDR get-version --verbose
GET /json_rpc HTTP/1.1
Host: rbpgdckle3h3vi4wwwrh75usqtoc5r3alohy7yyx57isynvay63nacyd.onion:18089
User-Agent: Go-http-client/1.1
Content-Length: 49
Content-Type: application/json
Accept-Encoding: gzip
{"id":"0","jsonrpc":"2.0","method":"get_version"}
HTTP/1.1 200 Ok
Content-Length: 150
Accept-Ranges: bytes
Content-Type: application/json
Last-Modified: Sun, 18 Jul 2021 21:10:57 GMT
Server: Epee-based
{
"id": "0",
"jsonrpc": "2.0",
"result": {
"release": true,
"status": "OK",
"untrusted": false,
"version": 196613
}
}
Release: true
Major: 3
Minor: 5
```
### Library
To consume `go-monero` as a library for your Go project:
```console
$ go get -u -v github.com/cirocosta/go-monero
```
`go-monero` exposes two high-level packages: `levin` and `rpc`.
The first (`levin`) is used for interacting with the p2p network via plain TCP
(optionally, Tor and I2P can also be used via socks5 proxy - see options).
For instance, to reach out to a node (of a particular address `addr`) and grab
its list of connected peers (information that comes out of the initial
handshake):
```golang
import (
"context"
"fmt"
"github.com/cirocosta/go-monero/pkg/levin"
)
func ListNodePeers(ctx context.Context, addr string) error {
// start a client - this will actually establish a TCP `connect()`ion
// with the other node.
//
client, err := levin.NewClient(ctx, addr)
if err != nil {
return fmt.Errorf("new client '%s': %w", addr, err)
}
// close the connection when done
//
defer client.Close()
// perform the handshake
//
pl, err := client.Handshake(ctx)
if err != nil {
return fmt.Errorf("handshake: %w", err)
}
// list the peers reported back (250 max per monero's implementation)
//
for addr := range pl.Peers {
fmt.Println(addr)
}
return nil
}
```
The second (`rpc`), is used to communicate with `monerod` 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
(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_test
import (
"context"
"fmt"
"github.com/cirocosta/go-monero/pkg/rpc"
"github.com/cirocosta/go-monero/pkg/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)
}
```
## License
See [LICENSE](./LICENSE).
## Thanks
Big thanks to the Monero community and other projects around cryptonote:
- `#monero-dev` (https://matrix.to/#/#freenode_#monero-dev:matrix.org)
- https://reddit.com/r/Monero
- https://github.com/cdiv1e12/py-levin
- https://github.com/cryptonotefoundation/cryptonote
- https://github.com/LeTurt/turtlegod
- https://github.com/monero-ecosystem/vanity-monero
## Donate
![xmr address](./assets/donate.png)
891B5keCnwXN14hA9FoAzGFtaWmcuLjTDT5aRTp65juBLkbNpEhLNfgcBn6aWdGuBqBnSThqMPsGRjWVQadCrhoAT6CnSL3
[CGO]: https://pkg.go.dev/cmd/cgo
[Go]: https://go.dev
[INSTALL.md]: ./INSTALL.md
[Monero]: https://getmonero.org/
[releases page]: https://github.com/cirocosta/go-monero/releases
[Tor support]: #tor-support
[docker]: https://docs.docker.com/

View file

@ -9,8 +9,8 @@ import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/pkg/monero"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/pkg/monero"
)
type generateCommand struct {

View file

@ -3,7 +3,7 @@ package daemon
import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
)
var RootCommand = &cobra.Command{

View file

@ -5,9 +5,9 @@ import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
type generateBlocksCommand struct {

View file

@ -5,9 +5,9 @@ import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
type getAlternateChainsCommand struct {

View file

@ -7,9 +7,9 @@ import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
type getBansCommand struct {

View file

@ -7,10 +7,10 @@ import (
"github.com/dustin/go-humanize"
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/constant"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/constant"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
type getBlockCommand struct {

View file

@ -5,9 +5,9 @@ import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
type getBlockCountCommand struct {

View file

@ -5,9 +5,9 @@ import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
type getBlockHeaderCommand struct {

View file

@ -5,9 +5,9 @@ import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
type getBlockHeadersRangeCommand struct {

View file

@ -5,8 +5,8 @@ import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
)
type getBlockTemplateCommand struct {

View file

@ -5,9 +5,9 @@ import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
type getCoinbaseTxSumCommand struct {

View file

@ -8,9 +8,9 @@ import (
"github.com/dustin/go-humanize"
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
type getConnectionsCommand struct {

View file

@ -5,9 +5,9 @@ import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
type getFeeEstimateCommand struct {

View file

@ -5,9 +5,9 @@ import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
type getHeightCommand struct {

View file

@ -7,9 +7,9 @@ import (
"github.com/dustin/go-humanize"
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
type getInfoCommand struct {

View file

@ -5,9 +5,9 @@ import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
type getLastBlockHeaderCommand struct {

View file

@ -6,9 +6,9 @@ import (
"github.com/dustin/go-humanize"
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
type getLimitCommand struct {

View file

@ -7,9 +7,9 @@ import (
"github.com/dustin/go-humanize"
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
type getNetStatsCommand struct {

View file

@ -5,9 +5,9 @@ import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
type getOutsCommand struct {

View file

@ -8,9 +8,9 @@ import (
"github.com/dustin/go-humanize"
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
type getPeerListCommand struct {

View file

@ -8,9 +8,9 @@ import (
"github.com/dustin/go-humanize"
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
type getPublicNodesCommand struct {

View file

@ -10,10 +10,10 @@ import (
"github.com/dustin/go-humanize"
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/constant"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/constant"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
type getTransactionCommand struct {

View file

@ -9,10 +9,10 @@ import (
"github.com/dustin/go-humanize"
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/constant"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/constant"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
type getTransactionPoolCommand struct {

View file

@ -8,9 +8,9 @@ import (
"github.com/dustin/go-humanize"
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
type getTransactionPoolStatsCommand struct {

View file

@ -5,9 +5,9 @@ import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
type getVersionCommand struct {

View file

@ -5,9 +5,9 @@ import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
type hardForkInfoCommand struct {

View file

@ -5,9 +5,9 @@ import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
type miningStatusCommand struct {

View file

@ -5,7 +5,7 @@ import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
)
type onGetBlockHashCommand struct {

View file

@ -7,8 +7,8 @@ import (
"github.com/dustin/go-humanize"
"github.com/gosuri/uitable"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
func prettyBlockHeader(table *uitable.Table, header daemon.BlockHeader) {

View file

@ -5,9 +5,9 @@ import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
type relayTxCommand struct {

View file

@ -7,9 +7,9 @@ import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
type rpcAccessTrackingCommand struct {

View file

@ -9,9 +9,9 @@ import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
type setBansCommand struct {

View file

@ -6,9 +6,9 @@ import (
"github.com/dustin/go-humanize"
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
type setLimitCommand struct {

View file

@ -6,9 +6,9 @@ import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
type setLogCategoriesCommand struct {

View file

@ -5,9 +5,9 @@ import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
type setLogLevelCommand struct {

View file

@ -5,9 +5,9 @@ import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
type startMiningCommand struct {

View file

@ -5,9 +5,9 @@ import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
type stopMiningCommand struct {

View file

@ -8,9 +8,9 @@ import (
"github.com/dustin/go-humanize"
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
type syncInfoCommand struct {

View file

@ -7,8 +7,8 @@ import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/pkg/zmq"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/pkg/zmq"
)
type zmqCommand struct {

View file

@ -8,7 +8,7 @@ import (
"github.com/spf13/cobra"
"golang.org/x/net/proxy"
"github.com/cirocosta/go-monero/pkg/levin"
"git.gammaspectra.live/P2Pool/go-monero/pkg/levin"
)
type peerListCommand struct {

View file

@ -6,8 +6,8 @@ import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/wallet"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/wallet"
)
type autoRefreshCommand struct {

View file

@ -3,7 +3,7 @@ package wallet
import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
)
var RootCommand = &cobra.Command{

View file

@ -5,9 +5,9 @@ import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/wallet"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/wallet"
)
type createAddressCommand struct {

View file

@ -5,9 +5,9 @@ import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/wallet"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/wallet"
)
type getAccountsCommand struct {

View file

@ -5,9 +5,9 @@ import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/wallet"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/wallet"
)
type getAddressCommand struct {

View file

@ -5,10 +5,10 @@ import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/constant"
"github.com/cirocosta/go-monero/pkg/rpc/wallet"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/constant"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/wallet"
)
type getBalanceCommand struct {

View file

@ -5,9 +5,9 @@ import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/wallet"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/wallet"
)
type getHeightCommand struct {

View file

@ -5,9 +5,9 @@ import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
"github.com/cirocosta/go-monero/cmd/monero/options"
"github.com/cirocosta/go-monero/pkg/rpc/wallet"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/options"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/wallet"
)
type refreshCommand struct {

View file

@ -7,11 +7,10 @@ import (
"github.com/gosuri/uitable"
"github.com/cirocosta/go-monero/pkg/constant"
"git.gammaspectra.live/P2Pool/go-monero/pkg/constant"
)
// JSON pushes to stdout a pretty printed representation of a given value `v`.
//
func JSON(v interface{}) error {
encoder := json.NewEncoder(os.Stdout)
encoder.SetIndent(" ", " ")
@ -25,7 +24,6 @@ func JSON(v interface{}) error {
// NewTable instantiates a new table instance that already has pre-defined
// options set so it's consistent across all pretty prints of the commands.
//
func NewTable() *uitable.Table {
table := uitable.New()

View file

@ -6,10 +6,10 @@ import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/commands/address"
"github.com/cirocosta/go-monero/cmd/monero/commands/daemon"
"github.com/cirocosta/go-monero/cmd/monero/commands/p2p"
"github.com/cirocosta/go-monero/cmd/monero/commands/wallet"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/commands/address"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/commands/daemon"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/commands/p2p"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/commands/wallet"
)
var (

View file

@ -8,20 +8,18 @@ import (
"github.com/spf13/cobra"
"github.com/cirocosta/go-monero/cmd/monero/display"
mhttp "github.com/cirocosta/go-monero/pkg/http"
"github.com/cirocosta/go-monero/pkg/rpc"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"github.com/cirocosta/go-monero/pkg/rpc/wallet"
"git.gammaspectra.live/P2Pool/go-monero/cmd/monero/display"
mhttp "git.gammaspectra.live/P2Pool/go-monero/pkg/http"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/wallet"
)
// RootOpts are global options available to all commands under this package.
//
var RootOpts = &options{}
// options is a set of flags that are shared between all commands in this
// package.
//
type options struct {
address string
mhttp.ClientConfig
@ -30,7 +28,6 @@ type options struct {
// AddrFmter provides the function that should be used when displaying
// addresses based on the adddresses formatting option.
//
func (o *options) AddrFmter() func(string) string {
if !o.shortenAddresses {
return func(s string) string {
@ -43,14 +40,12 @@ func (o *options) AddrFmter() func(string) string {
// Context generates a new `context.Context` already honouring the deadline
// specified in the options.
//
func (o *options) Context() (context.Context, context.CancelFunc) {
return context.WithTimeout(context.Background(), o.RequestTimeout)
}
// initializeFromEnv ensures that any variables not supplied via flags have
// been captures from the set of environment variables.
//
func (o *options) initializeFromEnv() {
if address := os.Getenv("MONERO_ADDRESS"); address != "" {
o.address = address
@ -58,7 +53,6 @@ func (o *options) initializeFromEnv() {
}
// Client instantiates a new daemon RPC client based on the options filled.
//
func (o *options) Client() (*daemon.Client, error) {
o.initializeFromEnv()
@ -79,7 +73,6 @@ func (o *options) Client() (*daemon.Client, error) {
// WalletClient instantiates a new wallet RPC client based on the options
// filled.
//
func (o *options) WalletClient() (*wallet.Client, error) {
o.initializeFromEnv()
@ -100,7 +93,6 @@ func (o *options) WalletClient() (*wallet.Client, error) {
// Bind binds the flags defined by `options` to a `cobra` command so that they
// can be filled either via comand arguments or environment variables.
//
func Bind(cmd *cobra.Command) {
cmd.PersistentFlags().BoolVarP(&RootOpts.Verbose,
"verbose", "v",

2
go.mod
View file

@ -1,4 +1,4 @@
module github.com/cirocosta/go-monero
module git.gammaspectra.live/P2Pool/go-monero
go 1.18

View file

@ -5,7 +5,7 @@ import (
"github.com/stretchr/testify/assert"
mhttp "github.com/cirocosta/go-monero/pkg/http"
mhttp "git.gammaspectra.live/P2Pool/go-monero/pkg/http"
)
func TestParseChallenge(t *testing.T) {

View file

@ -7,7 +7,7 @@ import (
"github.com/sclevine/spec/report"
"github.com/stretchr/testify/assert"
"github.com/cirocosta/go-monero/pkg/levin"
"git.gammaspectra.live/P2Pool/go-monero/pkg/levin"
)
func TestLevin(t *testing.T) {

View file

@ -7,7 +7,7 @@ import (
"github.com/sclevine/spec/report"
"github.com/stretchr/testify/assert"
"github.com/cirocosta/go-monero/pkg/levin"
"git.gammaspectra.live/P2Pool/go-monero/pkg/levin"
)
func TestPortableStorage(t *testing.T) {

View file

@ -5,7 +5,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/cirocosta/go-monero/pkg/monero"
"git.gammaspectra.live/P2Pool/go-monero/pkg/monero"
)
func TestSeed(t *testing.T) {

View file

@ -9,7 +9,7 @@ import (
"net/http"
"net/url"
mhttp "github.com/cirocosta/go-monero/pkg/http"
mhttp "git.gammaspectra.live/P2Pool/go-monero/pkg/http"
)
const (
@ -27,7 +27,6 @@ const (
// Client is a wrapper over a plain HTTP client providing methods that
// correspond to all RPC invocations to a `monerod` daemon, including
// restricted and non-restricted ones.
//
type Client struct {
// http is the underlying http client that takes care of sending
// requests and receiving the responses.
@ -45,19 +44,16 @@ type Client struct {
// clientOptions is a set of options that can be overridden to tweak the
// client's behavior.
//
type clientOptions struct {
HTTPClient *http.Client
}
// ClientOption defines a functional option for overriding optional client
// configuration parameters.
//
type ClientOption func(o *clientOptions)
// WithHTTPClient is a functional option for providing a custom HTTP client to
// be used for the HTTP requests made to a monero daemon.
//
func WithHTTPClient(v *http.Client) func(o *clientOptions) {
return func(o *clientOptions) {
o.HTTPClient = v
@ -69,7 +65,6 @@ func WithHTTPClient(v *http.Client) func(o *clientOptions) {
//
// The `address` might be either restricted (typically <ip>:18089) or not
// (typically <ip>:18081).
//
func NewClient(address string, opts ...ClientOption) (*Client, error) {
options := &clientOptions{}
@ -97,7 +92,6 @@ func NewClient(address string, opts ...ClientOption) (*Client, error) {
}
// ResponseEnvelope wraps all responses from the RPC server.
//
type ResponseEnvelope struct {
ID string `json:"id"`
JSONRPC string `json:"jsonrpc"`
@ -109,7 +103,6 @@ type ResponseEnvelope struct {
}
// RequestEnvelope wraps all requests made to the RPC server.
//
type RequestEnvelope struct {
ID string `json:"id"`
JSONRPC string `json:"jsonrpc"`
@ -118,7 +111,6 @@ type RequestEnvelope struct {
}
// Request makes requests to any endpoints, not assuming any particular format.
//
func (c *Client) RawRequest(ctx context.Context, endpoint string, params interface{}, response interface{}) error {
address := *c.address
address.Path = endpoint
@ -151,7 +143,6 @@ func (c *Client) RawRequest(ctx context.Context, endpoint string, params interfa
// JSONRPC issues a request for a particular method under the JSONRPC endpoint
// with the proper envolope for its requests and unwrapping of results for
// responses.
//
func (c *Client) JSONRPC(ctx context.Context, method string, params interface{}, response interface{}) error {
address := *c.address
address.Path = endpointJSONRPC
@ -193,7 +184,6 @@ func (c *Client) JSONRPC(ctx context.Context, method string, params interface{},
// submitRequest performs any generic HTTP request to the monero node targeted
// by this client making no assumptions about a particular endpoint.
//
func (c *Client) submitRequest(req *http.Request, response interface{}) error {
resp, err := c.http.Do(req)
if err != nil {

View file

@ -13,7 +13,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/cirocosta/go-monero/pkg/rpc"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc"
)
// nolint:funlen

View file

@ -4,8 +4,8 @@ import (
"context"
"fmt"
"github.com/cirocosta/go-monero/pkg/rpc"
"github.com/cirocosta/go-monero/pkg/rpc/daemon"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
// nolint

View file

@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/cirocosta/go-monero/pkg/zmq"
"git.gammaspectra.live/P2Pool/go-monero/pkg/zmq"
)
func TestJSONFromFrame(t *testing.T) {