Compare commits

...

34 Commits

Author SHA1 Message Date
jahway603 adcb453d6e Merge pull request 'New release of Version 0.2.0' (#64) from dev into master 2 days ago
jahway603 3d052d0059 Updated contrib/debian/changelog 2 days ago
jahway603 0871b2189b Added --aarch64 CLI option to Debian package build script 4 days ago
jahway603 c8eec398f8 added fakeroot check for Debian package building script 4 days ago
jahway603 6957432ea1 minor change to markdown table 5 days ago
jahway603 189f6587c2 Merge branch 'master' into dev 5 days ago
jahway603 4a8a608c83 Release v 0.2.0 is ready to go 5 days ago
jahway603 205c937172 Created smarter Debian .deb package creation script to resolve Issue #50 5 days ago
jahway603 97086b614f Updated manpage to resolve Issue #58 5 days ago
jahway603 b9ffa1737c Updated copyright years and included Hush copyright on files missing one to resolve Issue #31 5 days ago
jahway603 25a14186f2 implemented help system in Makefile 5 days ago
Duke 2c680fb03c Try to deal gracefully with clients sending expired txs 3 weeks ago
Duke 4c0806d39c Try to fix logging bug 3 weeks ago
onryo ba34dd4345 Update 'README.md' 2 months ago
jahway603 997af9b3c5 changes for debian package building 11 months ago
jahway603 d7de70346d Update 'util/RELEASE-new-version.sh' 11 months ago
jahway603 6e3fb56153 Merge pull request 'updated manpage' (#56) from dev into master 11 months ago
jahway603 b14f1fc4c0 created initial RELEASE script for devs 11 months ago
jahway603 686b290ada updated copyright years 11 months ago
jahway603 69fdfe580b added root_test.go 11 months ago
jahway603 d3f21bfa55 getting ready for new release 11 months ago
jahway603 6676cd1a45 updated lightwalletd manpage 11 months ago
jahway603 82563fd362 Merge pull request 'merging dev into master' (#55) from master into dev 11 months ago
jahway603 428e72dd8c Merge branch 'dev' into master 11 months ago
Duke 957af58d8b Support arbitrary params in CallRpcWithRetries 12 months ago
Duke 336d70c088 Use CallRpcWithRetries on other RPC methods 12 months ago
Duke 1b7a8cdeb2 We ain't got no stinking Orchard 12 months ago
Duke 82a2a3e9a6 Call getbestblockhash RPC with retries in case hushd is down 12 months ago
Duke 3090b635cc Update version and document it in readme 12 months ago
Duke f30c932603 Delete old unused code 12 months ago
Duke 108f89a6ea Update FirstRPC retry count to 20 12 months ago
Duke 78bcb21d8c Add a link to grpcurl for testing 1 year ago
Duke f076ea8e52 Add docs for lightwalletd with HSCs and for --http-bind-addr 1 year ago
Duke a5adf5ea49 Add --rpcport to readme 1 year ago
  1. 2
      AUTHORS
  2. 24
      Makefile
  3. 77
      README.md
  4. 6
      cmd/root.go
  5. 22
      cmd/root_test.go
  6. 257
      cmd/server/main.old
  7. 32
      cmd/server/main_test.old
  8. 3
      cmd/version.go
  9. 4
      common/cache.go
  10. 84
      common/common.go
  11. 4
      common/generatecerts.go
  12. 3
      common/logging/logging.go
  13. 7
      common/logging/logging_test.go
  14. 2
      common/mempool.go
  15. 28
      contrib/debian/changelog
  16. 7
      contrib/debian/control
  17. 4
      contrib/debian/copyright
  18. 5
      contrib/debian/files
  19. 83
      doc/man/lightwalletd.1
  20. 12
      frontend/rpc_client.go
  21. 20
      frontend/service.go
  22. 2
      main.go
  23. 2
      parser/block.go
  24. 2
      parser/block_header.go
  25. 3
      parser/block_header_test.go
  26. 3
      parser/block_test.go
  27. 3
      parser/fuzz.go
  28. 2
      parser/internal/bytestring/bytestring.go
  29. 3
      parser/internal/bytestring/bytestring_test.go
  30. 4
      parser/transaction.go
  31. 3
      parser/transaction_test.go
  32. 2
      parser/util.go
  33. 4
      start-tls.sh
  34. 4
      start.sh
  35. 105
      util/build-debian-package-SBC.sh
  36. 60
      util/build-debian-package.sh
  37. 2
      util/build.sh
  38. 2
      walletrpc/compact_formats.pb.go
  39. 2
      walletrpc/compact_formats.proto
  40. 3
      walletrpc/generate.go
  41. 2
      walletrpc/service.pb.go
  42. 6
      walletrpc/service.proto
  43. 12
      walletrpc/service_grpc.pb.go

2
AUTHORS

@ -1,4 +1,4 @@
# The Hush Developers
Jahway603 https://git.hush.is/jahway603 https://github.com/jahway603
jahway603 https://git.hush.is/jahway603 https://codeberg.org/jahway603 https://github.com/jahway603
Duke Leto https://git.hush.is/duke

24
Makefile

@ -1,26 +1,28 @@
# Copyright (c) 2021 Jahway603 & The Hush Developers
# Copyright (c) 2021-2024 Jahway603 & The Hush Developers
# Released under the GPLv3
#
# Hush Lightwalletd Makefile
# author: jahway603
#
.PHONY: format help
# Help system from https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
.DEFAULT_GOAL := help
PROJECT_NAME := "lightwalletd"
GOCMD=go
GOTEST=$(GOCMD) test
GOVET=$(GOCMD) vet
#.PHONY: build
help:
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
build:
# Build binary
build: ## Build binary for amd64 (x86_64) architecture
./util/build.sh
build-arm:
# Build binary for ARM architecture (aarch64)
build-arm: ## Build binary for ARM architecture (aarch64)
GOOS=linux GOARCH=arm64 ./util/build.sh
protobuf:
# Generate protobuf shizzle
protobuf: ## Generate protobuf shizzle
cd walletrpc && protoc --go_out=paths=source_relative:. service.proto compact_formats.proto && protoc --go-grpc_out=paths=source_relative:. service.proto
# Stop the hushd process in the hushdlwd container
@ -31,13 +33,13 @@ protobuf:
#docker_remove_all:
# docker system prune -f
dep:
dep: ## Pull dependencies (if needed)
@go get -v -d ./...
vendor:
vendor: ## Pull vendor files locally (if needed)
go mod tidy && go mod vendor
clean:
clean: ## Clean the project
@echo "Cleaning project $(PROJECT_NAME) files..."
rm -f $(PROJECT_NAME)
rm -rf /tmp/$(PROJECT_NAME)-*

77
README.md

@ -82,7 +82,10 @@ server {
# Replace 9067 with the port of your gRPC server if using a custom port
# Hush Smart Chains should use a different port than 9067 so it doesn't conflict with HUSH lightwalletd
# NOTE: it's only safe to use --no-tls on lightwalletd if this is on localhost
grpc_pass grpc://localhost:9067;
grpc_pass grpc://localhost:9067;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
```
@ -93,6 +96,13 @@ Then run the lightwalletd frontend with the following:
./start.sh
```
If you see the following error `"Can't create data directory: /var/lib/lightwalletd"` you need to set the correct user permissions:
```
sudo chown -R $USER:$USER /var/lib/lightwalletd
sudo chmod -R 755 /var/lib/lightwalletd
```
Note: we use the "--no-tls" option as we are using NGINX as a reverse proxy and letting it handle the TLS authentication for us instead. If you want to do TLS directly with lightwalletd with no reverse proxy, see the next section.
If you encounter an error about the lightwalletd "data directory", then set one on the command line with `--data-dir` (OR) create the `/var/lib/lightwalletd` and `/var/lib/lightwalletd/db` directories & chown that new db directory as the user account running lightwalletd and hushd.
@ -117,25 +127,50 @@ cargo build --release
* If you have trouble compiling silentdragonlite-cli, then [please refer to it's separate documentation here](https://git.hush.is/hush/silentdragonlite-cli) on how to build it and what pre-requisites need to be installed.
## Lightwalletd Command-line Options
You can also do testing with https://github.com/fullstorydev/grpcurl
These are some of the most used command line options for lightwalletd:
## Running a server for Hush Smart Chains
This lightwalletd code can be used with any Hush Smart Chain. For example, here is how you would
run the lightwalletd for DragonX :
```
./lightwalletd --grpc-bind-addr localhost:9069 --http-bind-addr localhost:9070 --hush-conf-path ~/.hush/DRAGONX/DRAGONX.conf --no-tls --rpcport=21769
```
For this code, your Nginx config will need to use the same GRPC port, so something like `grpc_pass grpc://localhost:9069;`
| CLI option | Default | What it does |
|------------|:--------------:|------------------------------:|
| --grpc-bind-addr | 127.0.0.1:9067 | address and port to listen on |
| --tls-cert | blank | the path to a TLS certificate |
| --tls-key | blank | the path to a TLS key file |
| --no-tls | false | Disable TLS, serve un-encrypted traffic |
| --data-dir | /var/lib/lightwalletd | Sets the lightwalletd data directory |
| --log-file | blank | log file to write to |
| --log-level | logrus.InfoLevel | log level 1 thru 7 (something from logrus)|
| --hush-conf-path | blank | conf file to pull RPC creds from |
| --cache-size| 40000 | number of blocks to hold in the cache |
The above code should be compatible with running a lightwalletd on the same server that runs one for Hush, which by default uses ports 9067 for grpc
and 9068 for http. If you are only running a single lightwalletd on a server, the following should work for DragonX :
```
./lightwalletd --grpc-bind-addr localhost:9069 --http-bind-addr localhost:9070 --hush-conf-path ~/.hush/DRAGONX/DRAGONX.conf --no-tls --rpcport=21769
```
To run lightwalletd for other HSC's, you must specific the correct RPC port via `--rpcport` , point to it's config file via `--hush-conf-path` and
use use unique ports that nothing else is using for `--grpc-bind-addr` and `--http-bind-addr` . Make sure your nginx config `grpc_pass` port matches
what you give to `--grpc-bin-addr` .
## Lightwalletd Command-line Options
These are some of the most used command line options for lightwalletd:
Run `./lightwalletd --help` to see all options.
| CLI option | Default | What it does |
|------------------|:--------------:|:------------------------------|
| --grpc-bind-addr | 127.0.0.1:9067 | address and port to listen on via GRPC |
| --http-bind-addr | 127.0.0.1:9068 | address and port to listen on vi HTTP |
| --tls-cert | blank | the path to a TLS certificate |
| --tls-key | blank | the path to a TLS key file |
| --no-tls | false | Disable TLS, serve un-encrypted traffic |
| --data-dir | /var/lib/lightwalletd | Sets the lightwalletd data directory |
| --log-file | blank | log file to write to |
| --log-level | logrus.InfoLevel | log level 1 thru 7 (something from logrus) |
| --hush-conf-path | blank | conf file to pull RPC creds from |
| --rpcport | 18031 | RPC port |
| version | n/a | Display lightwalletd version |
Run `./lightwalletd --help` or `./lightwalletd help` to see all options.
## Developing
@ -147,12 +182,18 @@ protoc --go_out=paths=source_relative:. foo.proto
Or do `make protobuf`
## Support
For support or other questions, join us on [Telegram](https://hush.is/telegram), or tweet at [@HushIsPrivacy](https://twitter.com/HushIsPrivacy), or toot at our [Mastodon](https://fosstodon.org/@myhushteam) or join [Telegram Support](https://hush.is/telegram_support).
To update the version of lightwalletd, update the value of the `Version` variable in common/common.go .
## Support and Socials
* Telegram: [https://hush.is/tg](https://hush.is/tg)
* Matrix: [https://hush.is/matrix](https://hush.is/matrix)
* Twitter: [https://hush.is/twitter](https://hush.is/twitter)
* PeerTube [https://hush.is/peertube](https://hush.is/peertube)
## License
GPLv3 or later
# Copyright
2016-2022 The Hush Developers
2016-2024 The Hush Developers

6
cmd/root.go

@ -1,4 +1,4 @@
// Copyright (c) 2019-2022 Duke Leto and The Hush developers
// Copyright (c) 2019-2024 Duke Leto and The Hush developers
// Copyright (c) 2019-2020 The Zcash developers
// Distributed under the GPLv3 software license
package cmd
@ -49,7 +49,7 @@ var rootCmd = &cobra.Command{
TLSKeyPath: viper.GetString("tls-key"),
LogLevel: viper.GetUint64("log-level"),
LogFile: viper.GetString("log-file"),
HushConfPath: viper.GetString("hush-conf-path"),
HushConfPath: viper.GetString("hush-conf-path"),
RPCUser: viper.GetString("rpcuser"),
RPCPassword: viper.GetString("rpcpassword"),
RPCHost: viper.GetString("rpchost"),
@ -204,7 +204,7 @@ func startServer(opts *common.Options) error {
// Indirect function for test mocking (so unit tests can talk to stub functions).
common.RawRequest = rpcClient.RawRequest
// Ensure that we can communicate with zcashd
// Ensure that we can communicate with hushd
common.FirstRPC()
getLightdInfo, err := common.GetLightdInfo()

22
cmd/root_test.go

@ -0,0 +1,22 @@
// Copyright (c) 2019-2024 Duke Leto and The Hush developers
// Copyright (c) 2019-2020 The Zcash developers
// Distributed under the GPLv3 software license
package cmd
import (
"testing"
)
func TestFileExists(t *testing.T) {
if fileExists("nonexistent-file") {
t.Fatal("fileExists unexpected success")
}
// If the path exists but is a directory, should return false
if fileExists(".") {
t.Fatal("fileExists unexpected success")
}
// The following file should exist, it's what's being tested
if !fileExists("root.go") {
t.Fatal("fileExists failed")
}
}

257
cmd/server/main.old

@ -1,257 +0,0 @@
package main
import (
"context"
"flag"
"fmt"
"net"
"os"
"os/signal"
"syscall"
"time"
"github.com/sirupsen/logrus"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/peer"
"google.golang.org/grpc/reflection"
"git.hush.is/hush/lightwalletd/common"
"git.hush.is/hush/lightwalletd/frontend"
"git.hush.is/hush/lightwalletd/walletrpc"
)
var log *logrus.Entry
var logger = logrus.New()
func init() {
logger.SetFormatter(&logrus.TextFormatter{
//DisableColors: true,
FullTimestamp: true,
DisableLevelTruncation: true,
})
log = logger.WithFields(logrus.Fields{
"app": "frontend-grpc",
})
}
// TODO stream logging
func LoggingInterceptor() grpc.ServerOption {
return grpc.UnaryInterceptor(logInterceptor)
}
func logInterceptor(
ctx context.Context,
req interface{},
info *grpc.UnaryServerInfo,
handler grpc.UnaryHandler,
) (interface{}, error) {
reqLog := loggerFromContext(ctx)
start := time.Now()
resp, err := handler(ctx, req)
entry := reqLog.WithFields(logrus.Fields{
"method": info.FullMethod,
"duration": time.Since(start),
"error": err,
})
if err != nil {
entry.Error("call failed")
} else {
entry.Info("method called")
}
return resp, err
}
func loggerFromContext(ctx context.Context) *logrus.Entry {
// TODO: anonymize the addresses. cryptopan?
if peerInfo, ok := peer.FromContext(ctx); ok {
return log.WithFields(logrus.Fields{"peer_addr": peerInfo.Addr})
}
return log.WithFields(logrus.Fields{"peer_addr": "unknown"})
}
type Options struct {
bindAddr string `json:"bind_address,omitempty"`
tlsCertPath string `json:"tls_cert_path,omitempty"`
tlsKeyPath string `json:"tls_cert_key,omitempty"`
noTLS bool `json:no_tls,omitempty`
logLevel uint64 `json:"log_level,omitempty"`
logPath string `json:"log_file,omitempty"`
hush3ConfPath string `json:"hush3_conf,omitempty"`
cacheSize int `json:"hush3_conf,omitempty"`
}
func main() {
var version = "0.1.1" // set version number
opts := &Options{}
flag.StringVar(&opts.bindAddr, "bind-addr", "127.0.0.1:9067", "the address to listen on")
flag.StringVar(&opts.tlsCertPath, "tls-cert", "", "the path to a TLS certificate (optional)")
flag.StringVar(&opts.tlsKeyPath, "tls-key", "", "the path to a TLS key file (optional)")
flag.BoolVar(&opts.noTLS, "no-tls", false, "Disable TLS, serve un-encrypted traffic.")
flag.Uint64Var(&opts.logLevel, "log-level", uint64(logrus.InfoLevel), "log level (logrus 1-7)")
flag.StringVar(&opts.logPath, "log-file", "", "log file to write to")
flag.StringVar(&opts.hush3ConfPath, "conf-file", "", "conf file to pull RPC creds from")
flag.IntVar(&opts.cacheSize, "cache-size", 40000, "number of blocks to hold in the cache")
// creating --version as a requirement of help2man
if len(os.Args) > 1 && (os.Args[1] == "--version" || os.Args[1] == "-v") {
fmt.Printf("Hush lightwalletd version " + version + "\n")
os.Exit(0)
}
// TODO prod metrics
// TODO support config from file and env vars
flag.Parse()
if opts.hush3ConfPath == "" {
flag.Usage()
os.Exit(1)
}
if !opts.noTLS && (opts.tlsCertPath == "" || opts.tlsKeyPath == "") {
println("Please specify a TLS certificate/key to use. You can use a self-signed certificate.")
println("See https://git.hush.is/hush/lightwalletd/src/branch/master/README.md#running-your-own-sdl-lightwalletd")
os.Exit(1)
}
if opts.logPath != "" {
// instead write parsable logs for logstash/splunk/etc
output, err := os.OpenFile(opts.logPath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
log.WithFields(logrus.Fields{
"error": err,
"path": opts.logPath,
}).Fatal("couldn't open log file")
}
defer output.Close()
logger.SetOutput(output)
logger.SetFormatter(&logrus.JSONFormatter{})
}
logger.SetLevel(logrus.Level(opts.logLevel))
// gRPC initialization
var server *grpc.Server
if !opts.noTLS && (opts.tlsCertPath != "" && opts.tlsKeyPath != "") {
transportCreds, err := credentials.NewServerTLSFromFile(opts.tlsCertPath, opts.tlsKeyPath)
if err != nil {
log.WithFields(logrus.Fields{
"cert_file": opts.tlsCertPath,
"key_path": opts.tlsKeyPath,
"error": err,
}).Fatal("couldn't load TLS credentials")
}
server = grpc.NewServer(grpc.Creds(transportCreds), LoggingInterceptor())
} else {
server = grpc.NewServer(LoggingInterceptor())
}
// Enable reflection for debugging
if opts.logLevel >= uint64(logrus.WarnLevel) {
reflection.Register(server)
}
// Initialize Hush RPC client. Right now (Jan 2018) this is only for
// sending transactions, but in the future it could back a different type
// of block streamer.
rpcClient, err := frontend.NewZRPCFromConf(opts.hush3ConfPath)
if err != nil {
log.WithFields(logrus.Fields{
"error": err,
}).Warn("HUSH3.conf failed, will try empty credentials for rpc")
rpcClient, err = frontend.NewZRPCFromCreds("127.0.0.1:18031", "", "")
if err != nil {
log.WithFields(logrus.Fields{
"error": err,
}).Warn("couldn't start rpc conn. won't be able to send transactions")
}
}
// Get the sapling activation height from the RPC
saplingHeight, blockHeight, chainName, branchID, difficulty, longestchain, notarized, err := common.GetSaplingInfo(rpcClient)
if err != nil {
log.WithFields(logrus.Fields{
"error": err,
}).Warn("Unable to get sapling activation height")
}
log.Info("Got sapling height ", saplingHeight, " chain ", chainName, " branchID ", branchID, " difficulty ", difficulty, longestchain, " longestchain ", notarized, " notarized ")
// Get the Coinsupply from the RPC
result, coin, height, supply, zfunds, total, err := common.GetCoinsupply(rpcClient)
if err != nil {
log.WithFields(logrus.Fields{
"error": err,
}).Warn("Unable to get coinsupply")
}
log.Info(" result ", result, " coin ", coin, " height", height, "supply", supply, "zfunds", zfunds, "total", total)
// Initialize the cache
cache := common.NewBlockCache(opts.cacheSize)
stopChan := make(chan bool, 1)
// Start the block cache importer at latestblock - 100k(cache size)
cacheStart := blockHeight - opts.cacheSize
if cacheStart < saplingHeight {
cacheStart = saplingHeight
}
go common.BlockIngestor(rpcClient, cache, log, stopChan, cacheStart)
// Compact transaction service initialization
service, err := frontend.NewSQLiteStreamer(rpcClient, cache, log)
if err != nil {
log.WithFields(logrus.Fields{
"error": err,
}).Fatal("couldn't create SQL backend")
}
defer service.(*frontend.SqlStreamer).GracefulStop()
// Register service
walletrpc.RegisterCompactTxStreamerServer(server, service)
// Start listening
listener, err := net.Listen("tcp", opts.bindAddr)
if err != nil {
log.WithFields(logrus.Fields{
"bind_addr": opts.bindAddr,
"error": err,
}).Fatal("couldn't create listener")
}
// Signal handler for graceful stops
signals := make(chan os.Signal, 1)
signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM)
go func() {
s := <-signals
log.WithFields(logrus.Fields{
"signal": s.String(),
}).Info("caught signal, stopping gRPC server")
// Stop the server
server.GracefulStop()
// Stop the block ingestor
stopChan <- true
}()
log.Infof("Starting gRPC server on %s", opts.bindAddr)
err = server.Serve(listener)
if err != nil {
log.WithFields(logrus.Fields{
"error": err,
}).Fatal("gRPC server exited")
}
}

32
cmd/server/main_test.old

@ -1,32 +0,0 @@
// Copyright 2021 The Hush developers
// Released under the GPLv3
package main
import (
"os"
"testing"
)
// TestFileExists checks whether or not the file exists
func TestFileExists(t *testing.T) {
if fileExists("nonexistent-file") {
t.Fatal("fileExists unexpected success")
}
// If the path exists but is a directory, should return false
if fileExists(".") {
t.Fatal("fileExists unexpected success")
}
// The following file should exist, it's what's being tested
if !fileExists("main.go") {
t.Fatal("fileExists failed")
}
}
// fileExists checks if file exists and is not directory to prevent further errors
func fileExists(filename string) bool {
info, err := os.Stat(filename)
if os.IsNotExist(err) {
return false
}
return !info.IsDir()
}

3
cmd/version.go

@ -1,3 +1,6 @@
// Copyright (c) 2019-2024 Duke Leto and The Hush developers
// Copyright (c) 2019-2020 The Zcash developers
// Distributed under the GPLv3 software license
package cmd
import (

4
common/cache.go

@ -1,4 +1,4 @@
// Copyright (c) 2019-2022 Duke Leto and The Hush developers
// Copyright (c) 2019-2024 Duke Leto and The Hush developers
// Copyright (c) 2019-2020 The Zcash developers
// Distributed under the GPLv3 software license
// Package common contains utilities that are shared by other packages.
@ -284,7 +284,7 @@ func (c *BlockCache) Add(height int, block *walletrpc.CompactBlock) error {
bheight := int(block.Height)
if bheight != height {
// This could only happen if zcashd returned the wrong
// This could only happen if hushd returned the wrong
// block (not the height we requested).
Log.Fatal("cache.Add wrong height: ", bheight, " expecting: ", height)
return nil

84
common/common.go

@ -1,24 +1,24 @@
// Copyright (c) 2019-2022 Duke Leto and The Hush developers
// Copyright (c) 2019-2024 Duke Leto and The Hush developers
// Copyright (c) 2019-2020 The Zcash developers
// Distributed under the GPLv3 software license
package common
import (
"encoding/hex"
"encoding/json"
"strconv"
"strings"
"time"
"git.hush.is/hush/lightwalletd/parser"
"git.hush.is/hush/lightwalletd/walletrpc"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"fmt"
"encoding/hex"
"encoding/json"
"strconv"
"strings"
"time"
"git.hush.is/hush/lightwalletd/parser"
"git.hush.is/hush/lightwalletd/walletrpc"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
// TODO: 'make build' will overwrite this string with the output of git-describe (tag)
var (
Version = "v0.1.2"
Version = "v0.2.0"
GitCommit = ""
Branch = ""
BuildDate = ""
@ -159,7 +159,7 @@ type (
//TODO: this function is not currently used, but some of it's code
// needs to be implemented elsewhere
func GetSaplingInfo() (int, int, string, string, int, int, int, error) {
result, rpcErr := RawRequest("getblockchaininfo", []json.RawMessage{})
result, rpcErr := CallRpcWithRetries("getblockchaininfo", []json.RawMessage{})
var err error
var errCode int64
@ -199,7 +199,8 @@ func GetSaplingInfo() (int, int, string, string, int, int, int, error) {
}
func GetLightdInfo() (*walletrpc.LightdInfo, error) {
result, rpcErr := RawRequest("getinfo", []json.RawMessage{})
params := []json.RawMessage{}
result, rpcErr := CallRpcWithRetries("getinfo", params)
if rpcErr != nil {
return nil, rpcErr
}
@ -209,7 +210,8 @@ func GetLightdInfo() (*walletrpc.LightdInfo, error) {
return nil, rpcErr
}
result, rpcErr = RawRequest("getblockchaininfo", []json.RawMessage{})
params = []json.RawMessage{}
result, rpcErr = CallRpcWithRetries("getblockchaininfo", params)
if rpcErr != nil {
return nil, rpcErr
}
@ -260,7 +262,7 @@ func FirstRPC() {
break
}
retryCount++
if retryCount > 10 {
if retryCount > 20 {
Log.WithFields(logrus.Fields{
"timeouts": retryCount,
}).Fatal("unable to issue getblockchaininfo RPC call to hushd node")
@ -273,8 +275,45 @@ func FirstRPC() {
}
}
func CallRpcWithRetries(method string, params []json.RawMessage) (json.RawMessage, error) {
retryCount := 0
maxRetries := 50
for {
// params := []json.RawMessage{}
result, err := RawRequest(method, params)
if err == nil {
if retryCount > 0 {
Log.Warn(fmt.Sprintf("%s RPC successful", method))
}
return result, err
break
}
retryCount++
if retryCount > maxRetries && method != "sendrawtransaction" {
Log.WithFields(logrus.Fields{
"timeouts": retryCount,
}).Fatal(fmt.Sprintf("unable to issue %s RPC call to hushd node", method))
}
if retryCount > maxRetries && method == "sendrawtransaction" {
// TODO: it would be better to only give up if the error is an expired tx
Log.WithFields(logrus.Fields{
"error": err.Error(),
"retry": retryCount,
}).Warn(fmt.Sprintf("giving up on %s rpc", method))
// TODO: return a better error
return nil, nil
}
Log.WithFields(logrus.Fields{
"error": err.Error(),
"retry": retryCount,
}).Warn(fmt.Sprintf("error with %s rpc, retrying...", method))
Time.Sleep(time.Duration(10+retryCount*5) * time.Second) // backoff
}
return nil, nil
}
func GetBlockChainInfo() (*HushdRpcReplyGetblockchaininfo, error) {
// we don't use CallRpcWithRetries here because the calling code does it already
result, rpcErr := RawRequest("getblockchaininfo", []json.RawMessage{})
if rpcErr != nil {
return nil, rpcErr
@ -288,7 +327,8 @@ func GetBlockChainInfo() (*HushdRpcReplyGetblockchaininfo, error) {
}
func GetCoinsupply() (string, string, int, int, int, int, error) {
result1, rpcErr := RawRequest("coinsupply", []json.RawMessage{})
params := []json.RawMessage{}
result1, rpcErr := CallRpcWithRetries("coinsupply", params)
var err error
var errCode int64
@ -337,13 +377,12 @@ func getBlockFromRPC(height int) (*walletrpc.CompactBlock, error) {
}
params[0] = heightJSON
// Fetch the block using the verbose option ("1") because it provides
// both the list of txids, which we're not yet able to compute for
// Orchard (V5) transactions, and the block hash (block ID), which
// both the list of txids and the block hash (block ID), which
// we need to fetch the raw data format of the same block. Don't fetch
// by height in case a reorg occurs between the two getblock calls;
// using block hash ensures that we're fetching the same block.
params[1] = json.RawMessage("1")
result, rpcErr := RawRequest("getblock", params)
result, rpcErr := CallRpcWithRetries("getblock", params)
if rpcErr != nil {
// Check to see if we are requesting a height the hushd doesn't have yet
if (strings.Split(rpcErr.Error(), ":"))[0] == "-8" {
@ -362,7 +401,7 @@ func getBlockFromRPC(height int) (*walletrpc.CompactBlock, error) {
}
params[0] = blockHash
params[1] = json.RawMessage("0") // non-verbose (raw hex)
result, rpcErr = RawRequest("getblock", params)
result, rpcErr = CallRpcWithRetries("getblock", params)
// For some reason, the error responses are not JSON
if rpcErr != nil {
@ -435,7 +474,8 @@ func BlockIngestor(c *BlockCache, rep int) {
default:
}
result, err := RawRequest("getbestblockhash", []json.RawMessage{})
params := []json.RawMessage{}
result, err := CallRpcWithRetries("getbestblockhash", params)
if err != nil {
Log.WithFields(logrus.Fields{
"error": err,

4
common/generatecerts.go

@ -1,6 +1,6 @@
// Copyright (c) 2019-2024 Duke Leto and The Hush developers
// Copyright (c) 2019-2020 The Zcash developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
// Distributed under the GPLv3 software license
package common
import (

3
common/logging/logging.go

@ -1,3 +1,6 @@
// Copyright (c) 2019-2024 Duke Leto and The Hush developers
// Copyright (c) 2019-2020 The Zcash developers
// Distributed under the GPLv3 software license
package logging
import (

7
common/logging/logging_test.go

@ -1,6 +1,6 @@
// Copyright (c) 2019-2024 Duke Leto and The Hush developers
// Copyright (c) 2019-2020 The Zcash developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
// Distributed under the GPLv3 software license
package logging
import (
@ -10,8 +10,9 @@ import (
"testing"
"errors"
"github.com/sirupsen/logrus"
"git.hush.is/hush/lightwalletd/common"
"github.com/sirupsen/logrus"
"google.golang.org/grpc"
"google.golang.org/grpc/peer"
)

2
common/mempool.go

@ -1,4 +1,4 @@
// Copyright (c) 2019-2022 Duke Leto and The Hush developers
// Copyright (c) 2019-2024 Duke Leto and The Hush developers
// Copyright (c) 2019-2020 The Zcash developers
// Distributed under the GPLv3 software license

28
contrib/debian/changelog

@ -1,5 +1,29 @@
lightwalletd (0.1.1) stable; urgency=medium
lightwalletd (0.2.0) unstable; urgency=high
* Fixed logging error
* Fixed issue with clients sending expired transactions
* Implemented help system in Makefile
* Updates to manpage to include all CLI options
* Updates to Documentation
-- Hush Core <jahway603@protonmail.com> Sat, 11 May 2024 09:44:17 -0700
lightwalletd (0.1.3) unstable; urgency=medium
* Bugfixes
* Removed old & unused code
-- Hush Core <jahway603@protonmail.com> Fri, 23 Jun 2023 06:39:17 -0700
lightwalletd (0.1.2) unstable; urgency=medium
* New codebase from upstream lightwalletd
* Updates to Documentation
-- Hush Core <jahway603@protonmail.com> Mon, 06 Mar 2023 07:18:21 -0700
lightwalletd (0.1.1) unstable; urgency=medium
* 0.1.1 release.
-- Hush Core <jahway603@protonmail.com> Sunday, 24 Oct 2021 13:40:30 -0700
-- Hush Core <jahway603@protonmail.com> Sun, 24 Oct 2021 13:40:30 -0700

7
contrib/debian/control

@ -2,12 +2,15 @@ Source: lightwalletd
Section: utils
Priority: optional
Maintainer: Jahway603 <jahway603@protonmail.com>
Build-Depends: go, libc6-dev
Standards-Version: 4.0.0
Homepage: https://hush.is
Build-Depends: go
Vcs-Git: https://git.hush.is/hush/lightwalletd.git
Vcs-Browser: https://git.hush.is/hush/lightwalletd
Package: lightwalletd
Architecture: amd64 arm64
Depends: ${shlibs:Depends}
Description: Hush lightwallet daemon to run a Silent Dragon Lite server. Speak And Transact Freely. Hush inherits from Bitcoin Protocol and Zcash Protocol and is focused on private communications.
Description: Hush lightwallet daemon to run a Silent Dragon Lite server.
Speak And Transact Freely with Hush, which inherits from Bitcoin Protocol and
Zcash Protocol and is focused on private communications.

4
contrib/debian/copyright

@ -1,6 +1,6 @@
Files: *
Copyright: 2019-2021, The Hush developers
Copyright: 2019-2024, The Hush developers
2018-2019, The Zcash developers
License: GPLv3
Comment: https://hush.is/developers
Comment: https://hush.is

5
contrib/debian/files

@ -1 +1,4 @@
lightwalletd_0.1.1_amd64.deb utils optional
lightwalletd_0.1.3_amd64.deb utils optional
lightwalletd_0.1.3_arm64.deb utils optional
lightwalletd_0.2.0_amd64.deb utils optional
lightwalletd_0.2.0_arm64.deb utils optional

83
doc/man/lightwalletd.1

@ -1,6 +1,6 @@
.TH LIGHTWALLET "1" "December 2022" "lightwalletd v0.1.2" "User Commands"
.TH LIGHTWALLETD "1" "May 2024" "lightwalletd v0.2.0" "User Commands"
.SH NAME
lightwalletd \- manual page for hush lightwalletd v0.1.2
lightwalletd \- manual page for hush lightwalletd v0.2.0
.SH DESCRIPTION
.B lightwalletd
runs a lightwallet daemon for a Hush Silent Dragon Lite node.
@ -12,60 +12,103 @@ please see <https://hush.is/security/>.
.B lightwalletd [options]
Start Hush lightwalletd
.TP
lightwalletd --help
lightwalletd completion
Generate the autocompletion script for the specified shell
.TP
lightwalletd help
List available command line options
.TP
lightwalletd --version
lightwalletd version
Display version information
.SH OPTIONS
.HP
\fB\-help | -h | -?
\fB\--help | help | -h | -?
.IP
Display command line options
.HP
\fB\--hush-conf-path\fR [conf_file location]
\fB\--config \fRstring
.IP
Configure your lightwalletd config file location (default is current directory, lightwalletd.yaml)
.HP
\fB\--data-dir \fR [location]
.IP
Configures your HUSH3.conf file location to pull RPC creds from (default "./HUSH3.conf")
Configure your lightwalletd data directory (such as db) (default "/var/lib/lightwalletd")
.HP
\fB\--data-dir\fR [location]
\fB\--gen-cert-very-insecure
.IP
Configures your lightwalletd data directory (such as db) (default "/var/lib/lightwalletd")
Configure lightwalled to run with a self-signed TLS certificate. ONLY do this for debugging & DO NOT use in production!
.HP
\fB\--grpc-bind-addr \fRlocalhost:chosen_port
.IP
The address to listen for grpc on (default "localhost:9067")
Configure the address and port to listen for grpc on (default "localhost:9067")
.HP
\fB\--grpc-logging-insecure
.IP
Configure lightwalled to enable grpc logging to stderr
.HP
\fB\--http-bind-addr \fRstring
.IP
Configure the address and port to listen for http on (default "localhost:9068")
.HP
\fB\--hush-conf-path\fR [conf_file location]
.IP
Configure your HUSH3.conf file location to pull RPC creds from (default "./HUSH3.conf")
.HP
\fB\--log-file \fRstring
.IP
Configure log file to write to (default "./server.log")
.HP
\fB\--log-level \fRint
.IP
Configure log level (logrus 1-7) (default 4)
.HP
\fB\--no-tls
.IP
Run without TLS, only safe if a reverse proxy like nginx does TLS on localhost.
.HP
\fB\--cache-size \fRint
\fB\--ping-very-insecure
.IP
Set number of blocks to hold in the cache (default 40000)
Configure lightwalled to allow Ping GRPC for testing.
.HP
\fB\--log-file \fRstring
\fB\--redownload
.IP
Re-fetch all blocks from hushd; reinitialize local cache files
.HP
\fB\--rpchost \fRstring
.IP
Configure RPC host used.
.HP
\fB\--rpcpassword \fRstring
.IP
Configure RPC password used (default value used from HUSH3.conf)
.HP
\fB\--rpcport \fRstring
.IP
Configure RPC host port used (default value used from HUSH3.conf)
.HP
\fB\--rpcuser \fRstring
.IP
Set log file to write to
Configure RPC username used (default value used from HUSH3.conf)
.HP
\fB\--log-level \fRuint
\fB\--sync-from-height \fRint
.IP
log level (logrus 1-7) (default 4)
Re-fetch blocks from hushd start at this height (default -1)
.HP
\fB\--tls-cert \fRstring
.IP
the path to a TLS certificate (optional)
Configure the path to a TLS certificate (default "./cert.pem")
.HP
\fB\--tls-key \fRstring
.IP
the path to a TLS key file (optional)
Configure the path to a TLS key file (default "./cert.key")
.SH COPYRIGHT
In order to ensure you are adequately protecting your privacy when using Hush,
please see <https://hush.is/security/>.
Copyright (C) 2021-2022 Jahway603 and The Hush Developers
Copyright (C) 2021-2024 Jahway603 and The Hush Developers
This is experimental Free Software! Fuck Yeah!!!!!
Distributed under the GPLv3 software license, see the accompanying file COPYING
Distributed under the GPLv3 software license, see the accompanying file LICENSE
or <https://www.gnu.org/licenses/gpl-3.0.en.html>.

12
frontend/rpc_client.go

@ -1,4 +1,4 @@
// Copyright (c) 2019-2022 Duke Leto and The Hush developers
// Copyright (c) 2019-2024 Duke Leto and The Hush developers
// Copyright (c) 2019-2020 The Zcash developers
// Distributed under the GPLv3 software license
package frontend
@ -6,9 +6,9 @@ package frontend
import (
"net"
"git.hush.is/hush/lightwalletd/common"
"github.com/btcsuite/btcd/rpcclient"
"github.com/pkg/errors"
"git.hush.is/hush/lightwalletd/common"
ini "gopkg.in/ini.v1"
)
@ -26,15 +26,15 @@ func NewZRPCFromConf(confPath string) (*rpcclient.Client, error) {
return NewZRPCFromCreds(net.JoinHostPort(rpcaddr, rpcport), username, password)
}
// NewZRPCFromFlags gets zcashd rpc connection information from provided flags.
// NewZRPCFromFlags gets hushd rpc connection information from provided flags.
func NewZRPCFromFlags(opts *common.Options) (*rpcclient.Client, error) {
// Connect to local Zcash RPC server using HTTP POST mode.
// Connect to local Hush RPC server using HTTP POST mode.
connCfg := &rpcclient.ConnConfig{
Host: net.JoinHostPort(opts.RPCHost, opts.RPCPort),
User: opts.RPCUser,
Pass: opts.RPCPassword,
HTTPPostMode: true, // Zcash only supports HTTP POST mode
DisableTLS: true, // Zcash does not provide TLS by default
HTTPPostMode: true, // Hush only supports HTTP POST mode
DisableTLS: true, // Hush does not provide TLS by default
}
return rpcclient.New(connCfg, nil)
}

20
frontend/service.go

@ -1,4 +1,4 @@
// Copyright (c) 2019-2022 Duke Leto and The Hush developers
// Copyright (c) 2019-2024 Duke Leto and The Hush developers
// Copyright (c) 2019-2020 The Zcash developers
// Distributed under the GPLv3 software license
// Package frontend implements the gRPC handlers called by the wallets.
@ -95,7 +95,7 @@ func (s *lwdStreamer) GetTaddressTxids(addressBlockFilter *walletrpc.Transparent
return err
}
params[0] = param
result, rpcErr := common.RawRequest("getaddresstxids", params)
result, rpcErr := common.CallRpcWithRetries("getaddresstxids", params)
// For some reason, the error responses are not JSON
if rpcErr != nil {
@ -200,7 +200,7 @@ func (s *lwdStreamer) GetTransaction(ctx context.Context, txf *walletrpc.TxFilte
leHashStringJSON,
json.RawMessage("1"),
}
result, rpcErr := common.RawRequest("getrawtransaction", params)
result, rpcErr := common.CallRpcWithRetries("getrawtransaction", params)
// For some reason, the error responses are not JSON
if rpcErr != nil {
@ -258,7 +258,7 @@ func (s *lwdStreamer) GetCoinsupply(ctx context.Context, in *walletrpc.Empty) (*
}, nil
}
// SendTransaction forwards raw transaction bytes to a zcashd instance over JSON-RPC
// SendTransaction forwards raw transaction bytes to a full node over JSON-RPC
func (s *lwdStreamer) SendTransaction(ctx context.Context, rawtx *walletrpc.RawTransaction) (*walletrpc.SendResponse, error) {
// sendrawtransaction "hexstring" ( allowhighfees )
//
@ -279,7 +279,7 @@ func (s *lwdStreamer) SendTransaction(ctx context.Context, rawtx *walletrpc.RawT
return &walletrpc.SendResponse{}, err
}
params[0] = txJSON
result, rpcErr := common.RawRequest("sendrawtransaction", params)
result, rpcErr := common.CallRpcWithRetries("sendrawtransaction", params)
var errCode int64
var errMsg string
@ -325,7 +325,7 @@ func getTaddressBalanceHushdRpc(addressList []string) (*walletrpc.Balance, error
}
params[0] = param
result, rpcErr := common.RawRequest("getaddressbalance", params)
result, rpcErr := common.CallRpcWithRetries("getaddressbalance", params)
if rpcErr != nil {
return &walletrpc.Balance{}, rpcErr
}
@ -353,7 +353,7 @@ func getAddressUtxos(arg *walletrpc.GetAddressUtxosArg, f func(*walletrpc.GetAdd
return err
}
params[0] = param
result, rpcErr := common.RawRequest("getaddressutxos", params)
result, rpcErr := common.CallRpcWithRetries("getaddressutxos", params)
if rpcErr != nil {
return rpcErr
}
@ -431,7 +431,7 @@ func (s *lwdStreamer) GetMempoolStream(_empty *walletrpc.Empty, resp walletrpc.C
var mempoolMap *map[string]*walletrpc.CompactTx
var mempoolList []string
// Last time we pulled a copy of the mempool from zcashd.
// Last time we pulled a copy of the mempool from hushd
var lastMempool time.Time
func (s *lwdStreamer) GetMempoolTx(exclude *walletrpc.Exclude, resp walletrpc.CompactTxStreamer_GetMempoolTxServer) error {
@ -442,7 +442,7 @@ func (s *lwdStreamer) GetMempoolTx(exclude *walletrpc.Exclude, resp walletrpc.Co
lastMempool = time.Now()
// Refresh our copy of the mempool.
params := make([]json.RawMessage, 0)
result, rpcErr := common.RawRequest("getrawmempool", params)
result, rpcErr := common.CallRpcWithRetries("getrawmempool", params)
if rpcErr != nil {
return rpcErr
}
@ -467,7 +467,7 @@ func (s *lwdStreamer) GetMempoolTx(exclude *walletrpc.Exclude, resp walletrpc.Co
// The "0" is because we only need the raw hex, which is returned as
// just a hex string, and not even a json string (with quotes).
params := []json.RawMessage{txidJSON, json.RawMessage("0")}
result, rpcErr := common.RawRequest("getrawtransaction", params)
result, rpcErr := common.CallRpcWithRetries("getrawtransaction", params)
if rpcErr != nil {
// Not an error; mempool transactions can disappear
continue

2
main.go

@ -1,4 +1,4 @@
// Copyright (c) 2019-2022 Duke Leto and The Hush developers
// Copyright (c) 2019-2024 Duke Leto and The Hush developers
// Copyright (c) 2019-2020 The Zcash developers
// Distributed under the GPLv3 software license
package main

2
parser/block.go

@ -1,4 +1,4 @@
// Copyright (c) 2019-2022 Duke Leto and The Hush developers
// Copyright (c) 2019-2024 Duke Leto and The Hush developers
// Copyright (c) 2019-2020 The Zcash developers
// Distributed under the GPLv3 software license

2
parser/block_header.go

@ -1,4 +1,4 @@
// Copyright (c) 2019-2022 Duke Leto and The Hush developers
// Copyright (c) 2019-2024 Duke Leto and The Hush developers
// Copyright (c) 2019-2020 The Zcash developers
// Distributed under the GPLv3 software license
package parser

3
parser/block_header_test.go

@ -1,3 +1,6 @@
// Copyright (c) 2019-2024 Duke Leto and The Hush developers
// Copyright (c) 2019-2020 The Zcash developers
// Distributed under the GPLv3 software license
package parser
import (

3
parser/block_test.go

@ -1,3 +1,6 @@
// Copyright (c) 2019-2024 Duke Leto and The Hush developers
// Copyright (c) 2019-2020 The Zcash developers
// Distributed under the GPLv3 software license
package parser
import (

3
parser/fuzz.go

@ -1,3 +1,6 @@
// Copyright (c) 2019-2024 Duke Leto and The Hush developers
// Copyright (c) 2019-2020 The Zcash developers
// Distributed under the GPLv3 software license
// +build gofuzz
package parser

2
parser/internal/bytestring/bytestring.go

@ -1,4 +1,4 @@
// Copyright (c) 2019-2022 Duke Leto and The Hush developers
// Copyright (c) 2019-2024 Duke Leto and The Hush developers
// Copyright (c) 2019-2020 The Zcash developers
// Distributed under the GPLv3 software license

3
parser/internal/bytestring/bytestring_test.go

@ -1,3 +1,6 @@
// Copyright (c) 2019-2024 Duke Leto and The Hush developers
// Copyright (c) 2019-2020 The Zcash developers
// Distributed under the GPLv3 software license
package bytestring
import (

4
parser/transaction.go

@ -1,4 +1,4 @@
// Copyright (c) 2019-2022 Duke Leto and The Hush developers
// Copyright (c) 2019-2024 Duke Leto and The Hush developers
// Copyright (c) 2019-2020 The Zcash developers
// Distributed under the GPLv3 software license
// Package parser deserializes (full) transactions from hushd
@ -336,7 +336,7 @@ func (p *action) ToCompact() *walletrpc.CompactOrchardAction {
}
*/
// Transaction encodes a full (zcashd) transaction.
// Transaction encodes a full (hushd) transaction.
type Transaction struct {
*rawTransaction
rawBytes []byte

3
parser/transaction_test.go

@ -1,3 +1,6 @@
// Copyright (c) 2019-2024 Duke Leto and The Hush developers
// Copyright (c) 2019-2020 The Zcash developers
// Distributed under the GPLv3 software license
package parser
import (

2
parser/util.go

@ -1,4 +1,4 @@
// Copyright (c) 2019-2022 Duke Leto and The Hush developers
// Copyright (c) 2019-2024 Duke Leto and The Hush developers
// Copyright (c) 2019-2020 The Zcash developers
// Distributed under the GPLv3 software license
// Package parser deserializes (full) transactions from hushd

4
start-tls.sh

@ -1,5 +1,5 @@
#!/bin/bash
# Copyright 2020-2022 The Hush Developers
#!/usr/bin/env bash
# Copyright 2020-2024 The Hush Developers
# Released under GPLv3
# Description: This script would be used with a NGINX reverse proxy

4
start.sh

@ -1,5 +1,5 @@
#!/bin/bash
# Copyright 2020-2022 The Hush Developers
#!/usr/bin/env bash
# Copyright 2020-2024 The Hush Developers
# Released under GPLv3
# Description: This script would be used with a NGINX reverse proxy

105
util/build-debian-package-SBC.sh

@ -1,105 +0,0 @@
#!/usr/bin/env bash
# Copyright (c) 2021 The Hush developers
# Distributed under the GPLv3 software license, see the accompanying
# file LICENSE or https://www.gnu.org/licenses/gpl-3.0.en.html
#
# Remix for SBC (Single Board Computer) like PineBook, Rock64, Raspberry Pi, etc.
## Usage: ./util/build-debian-package-SBC.sh
echo "Let's see who read the README.md or not..."
echo ""
# Check if lightwalletd is already built on system and exit if it is not
if ! [ -x "$(command -v ./lightwalletd)" ]; then
echo 'Error: lightwalletd is not compiled yet. Run "make build" and try again.' >&2
echo ""
exit 1
fi
# Check if lintian is installed and exit if it is not
if ! [ -x "$(command -v lintian)" ]; then
echo 'Error: lintian is not installed yet. Consult your Linux version package manager...' >&2
echo 'On Debian/Ubuntu, try "sudo apt install lintian"'
echo ""
exit 1
fi
# Check if fakeroot is installed and exit if it is not
if ! [ -x "$(command -v fakeroot)" ]; then
echo 'Error: fakeroot is not installed yet. Consult your Linux version package manager...' >&2
echo 'On Debian/Ubuntu, try "sudo apt install fakeroot"'
echo ""
exit 1
fi
# TODO - check that the lightwalletd binary is not x86 and is actually aarch64
echo "Let There Be Hush Lightwalletd Debian Packages for ARM!!!"
echo ""
echo "((_,...,_))"
echo " |o o|"
echo " \ /"
echo " ^_^ cp97"
echo ""
set -e
set -x
BUILD_PATH="/tmp/lightwalletd-debian-$$"
PACKAGE_NAME="lightwalletd"
SRC_PATH=`pwd`
SRC_DEB=$SRC_PATH/contrib/debian
SRC_DOC=$SRC_PATH/doc
ARCH="aarch64"
umask 022
if [ ! -d $BUILD_PATH ]; then
mkdir $BUILD_PATH
fi
PACKAGE_VERSION=0.1.1
DEBVERSION=$(echo $PACKAGE_VERSION)
BUILD_DIR="$BUILD_PATH/$PACKAGE_NAME-$PACKAGE_VERSION-$ARCH"
if [ -d $BUILD_DIR ]; then
rm -R $BUILD_DIR
fi
DEB_BIN=$BUILD_DIR/usr/bin
DEB_CMP=$BUILD_DIR/usr/share/bash-completion/completions
DEB_DOC=$BUILD_DIR/usr/share/doc/$PACKAGE_NAME
DEB_MAN=$BUILD_DIR/usr/share/man/man1
DEB_SHR=$BUILD_DIR/usr/share/hush
mkdir -p $BUILD_DIR/DEBIAN $DEB_CMP $DEB_BIN $DEB_DOC $DEB_MAN $DEB_SHR
chmod 0755 -R $BUILD_DIR/*
# Package maintainer scripts (currently empty)
#cp $SRC_DEB/postinst $BUILD_DIR/DEBIAN
#cp $SRC_DEB/postrm $BUILD_DIR/DEBIAN
#cp $SRC_DEB/preinst $BUILD_DIR/DEBIAN
#cp $SRC_DEB/prerm $BUILD_DIR/DEBIAN
# Copy binary
cp $SRC_PATH/lightwalletd $DEB_BIN/lightwalletd
strip $DEB_BIN/lightwalletd
cp $SRC_DEB/changelog $DEB_DOC
cp $SRC_DEB/copyright $DEB_DOC
cp -r $SRC_DEB/examples $DEB_DOC
# Copy manpage
cp $SRC_DOC/man/lightwalletd.1 $DEB_MAN/lightwalletd.1
# Gzip files
gzip --best -n $DEB_MAN/lightwalletd.1
cd $SRC_PATH/contrib
# Create the control file
dpkg-shlibdeps $DEB_BIN/lightwalletd
dpkg-gencontrol -P$BUILD_DIR -v$DEBVERSION
# Create the Debian package
fakeroot dpkg-deb --build $BUILD_DIR
cp $BUILD_PATH/$PACKAGE_NAME-$PACKAGE_VERSION-$ARCH.deb $SRC_PATH
shasum -a 256 $SRC_PATH/$PACKAGE_NAME-$PACKAGE_VERSION-$ARCH.deb
# Analyze with Lintian, reporting bugs and policy violations
lintian -i $SRC_PATH/$PACKAGE_NAME-$PACKAGE_VERSION-$ARCH.deb
exit 0

60
util/build-debian-package.sh

@ -1,11 +1,22 @@
#!/bin/bash
# Copyright (c) 2021 The Hush developers
#!/usr/bin/env bash
# Copyright (c) 2021-2024 The Hush developers
# Distributed under the GPLv3 software license, see the accompanying
# file LICENSE or https://www.gnu.org/licenses/gpl-3.0.en.html
#
## Usage: ./util/build-debian-package.sh
## USAGE
# ./util/build-debian-package.sh <architecture flag> <version-you-are-building>
#
## Example to build debian pkg for amd64 (most common) for version 0.2.0:
# ./util/build-debian-package.sh --amd64 0.2.0
#
## Example to build debian pkg for ARM (aarch64) for version 0.2.0:
# ./util/build-debian-package.sh --arm 0.2.0
#
## USAGE Requirements:
# - Needs to be run in lightwalletd root directory
# - Needs to be run on a Debian system (NOT UBUNTU)
echo "Let's see who read the README.md or not..."
echo "Let's see who read the USAGE EXAMPLES in this script or not..."
echo ""
# Check if lightwalletd is already built on system and exit if it is not
@ -16,11 +27,36 @@ if ! [ -x "$(command -v ./lightwalletd)" ]; then
fi
# Check if lintian is installed and exit if it is not
#if ! [ -x "$(command -v lintian)" ]; then
# echo 'Error: lintian is not installed yet. Consult your Linux version package manager...' >&2
# echo ""
# exit 1
#fi
if ! [ -x "$(command -v lintian)" ]; then
echo 'Error: lintian is not installed yet. Consult your Linux version package manager...' >&2
echo 'On Debian/Ubuntu, try "sudo apt install lintian"'
echo ""
exit 1
fi
# Check if fakeroot is installed and exit if it is not
if ! [ -x "$(command -v fakeroot)" ]; then
echo 'Error: fakeroot is not installed yet. Consult your Linux version package manager...' >&2
echo 'On Debian/Ubuntu, try "sudo apt install fakeroot"'
echo ""
exit 1
fi
## Command line options section
# Check if there are no CLI options entered and exit if so
if [ -z "$1" ] || [ -z "$2" ]; then
echo 'YOU DOING IT WRONG...' >&2
echo 'Read the Usage Examples at top of this script & TRY AGAIN' >&2
exit 1
fi
# Architecture CLI option
if [ "$1" = "--amd64" -o "$1" = "--a64" ]; then
ARCH="amd64"
elif [ "$1" = "--arm" -o "$1" = "--ARM" -o "$1" = "--aarch64" ]; then
ARCH="aarch64"
fi
# Set Version-to-build from Second CLI option
PACKAGE_VERSION=$2
echo "Let There Be Hush Lightwalletd Debian Packages!"
echo ""
@ -38,7 +74,6 @@ PACKAGE_NAME="lightwalletd"
SRC_PATH=`pwd`
SRC_DEB=$SRC_PATH/contrib/debian
SRC_DOC=$SRC_PATH/doc
ARCH="amd64"
umask 022
@ -46,7 +81,6 @@ if [ ! -d $BUILD_PATH ]; then
mkdir $BUILD_PATH
fi
PACKAGE_VERSION=0.1.1
DEBVERSION=$(echo $PACKAGE_VERSION)
BUILD_DIR="$BUILD_PATH/$PACKAGE_NAME-$PACKAGE_VERSION-$ARCH"
@ -92,7 +126,5 @@ fakeroot dpkg-deb --build $BUILD_DIR
cp $BUILD_PATH/$PACKAGE_NAME-$PACKAGE_VERSION-$ARCH.deb $SRC_PATH
shasum -a 256 $SRC_PATH/$PACKAGE_NAME-$PACKAGE_VERSION-$ARCH.deb
# Analyze with Lintian, reporting bugs and policy violations
# Arch does not have lintian, as it's a Debian package, so commenting this out
# To-DO - test on Debian/Ubuntu, create AUR lintian package
#lintian -i $SRC_PATH/$PACKAGE_NAME-$PACKAGE_VERSION-$ARCH.deb
lintian -i $SRC_PATH/$PACKAGE_NAME-$PACKAGE_VERSION-$ARCH.deb
exit 0

2
util/build.sh

@ -1,5 +1,5 @@
#!/usr/bin/env bash
# Copyright 2021-2022 Duke Leto and The Hush Developers
# Copyright 2021-2024 Duke Leto and The Hush Developers
# Distributed under the GPLv3 software license, see the accompanying
# file LICENSE or https://www.gnu.org/licenses/gpl-3.0.en.html
# Purpose: Script to build Hush lightwalletd on x86 64-bit arch

2
walletrpc/compact_formats.pb.go

@ -1,4 +1,4 @@
// Copyright (c) 2019-2022 Duke Leto and The Hush developers
// Copyright (c) 2019-2024 Duke Leto and The Hush developers
// Copyright (c) 2019-2020 The Zcash developers
// Distributed under the GPLv3 software license

2
walletrpc/compact_formats.proto

@ -1,4 +1,4 @@
// Copyright (c) 2019-2022 Duke Leto and The Hush developers
// Copyright (c) 2019-2024 Duke Leto and The Hush developers
// Copyright (c) 2019-2020 The Zcash developers
// Distributed under the GPLv3 software license
syntax = "proto3";

3
walletrpc/generate.go

@ -1,3 +1,6 @@
// Copyright (c) 2019-2024 Duke Leto and The Hush developers
// Copyright (c) 2019-2020 The Zcash developers
// Distributed under the GPLv3 software license
package walletrpc
//go:generate protoc -I . ./compact_formats.proto --go_out=plugins=grpc:.

2
walletrpc/service.pb.go

@ -1,4 +1,4 @@
// Copyright (c) 2019-2022 Duke Leto and The Hush developers
// Copyright (c) 2019-2024 Duke Leto and The Hush developers
// Copyright (c) 2019-2020 The Zcash developers
// Distributed under the GPLv3 software license

6
walletrpc/service.proto

@ -1,4 +1,4 @@
// Copyright (c) 2019-2022 Duke Leto and The Hush developers
// Copyright (c) 2019-2024 Duke Leto and The Hush developers
// Copyright (c) 2019-2020 The Zcash developers
// Distributed under the GPLv3 software license
syntax = "proto3";
@ -128,9 +128,9 @@ service CompactTxStreamer {
// Return a list of consecutive compact blocks
rpc GetBlockRange(BlockRange) returns (stream CompactBlock) {}
// Return the requested full (not compact) transaction (as from zcashd)
// Return the requested full (not compact) transaction (as from hushd)
rpc GetTransaction(TxFilter) returns (RawTransaction) {}
// Submit the given transaction to the Zcash network
// Submit the given transaction to the Hush network
rpc SendTransaction(RawTransaction) returns (SendResponse) {}
// Return the txids corresponding to the given t-address within the given block range

12
walletrpc/service_grpc.pb.go

@ -1,3 +1,7 @@
// Copyright (c) 2019-2024 Duke Leto and The Hush developers
// Copyright (c) 2019-2020 The Zcash developers
// Distributed under the GPLv3 software license
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
package walletrpc
@ -24,9 +28,9 @@ type CompactTxStreamerClient interface {
GetBlock(ctx context.Context, in *BlockID, opts ...grpc.CallOption) (*CompactBlock, error)
// Return a list of consecutive compact blocks
GetBlockRange(ctx context.Context, in *BlockRange, opts ...grpc.CallOption) (CompactTxStreamer_GetBlockRangeClient, error)
// Return the requested full (not compact) transaction (as from zcashd)
// Return the requested full (not compact) transaction (as from hushd)
GetTransaction(ctx context.Context, in *TxFilter, opts ...grpc.CallOption) (*RawTransaction, error)
// Submit the given transaction to the Zcash network
// Submit the given transaction to the Hush network
SendTransaction(ctx context.Context, in *RawTransaction, opts ...grpc.CallOption) (*SendResponse, error)
// Return the txids corresponding to the given t-address within the given block range
GetTaddressTxids(ctx context.Context, in *TransparentAddressBlockFilter, opts ...grpc.CallOption) (CompactTxStreamer_GetTaddressTxidsClient, error)
@ -396,9 +400,9 @@ type CompactTxStreamerServer interface {
GetBlock(context.Context, *BlockID) (*CompactBlock, error)
// Return a list of consecutive compact blocks
GetBlockRange(*BlockRange, CompactTxStreamer_GetBlockRangeServer) error
// Return the requested full (not compact) transaction (as from zcashd)
// Return the requested full (not compact) transaction (as from hushd)
GetTransaction(context.Context, *TxFilter) (*RawTransaction, error)
// Submit the given transaction to the Zcash network
// Submit the given transaction to the Hush network
SendTransaction(context.Context, *RawTransaction) (*SendResponse, error)
// Return the txids corresponding to the given t-address within the given block range
GetTaddressTxids(*TransparentAddressBlockFilter, CompactTxStreamer_GetTaddressTxidsServer) error

Loading…
Cancel
Save