Compare commits
34 Commits
Author | SHA1 | Date |
---|---|---|
jahway603 | adcb453d6e | 2 days ago |
jahway603 | 3d052d0059 | 2 days ago |
jahway603 | 0871b2189b | 4 days ago |
jahway603 | c8eec398f8 | 4 days ago |
jahway603 | 6957432ea1 | 5 days ago |
jahway603 | 189f6587c2 | 5 days ago |
jahway603 | 4a8a608c83 | 5 days ago |
jahway603 | 205c937172 | 5 days ago |
jahway603 | 97086b614f | 5 days ago |
jahway603 | b9ffa1737c | 5 days ago |
jahway603 | 25a14186f2 | 5 days ago |
Duke | 2c680fb03c | 3 weeks ago |
Duke | 4c0806d39c | 3 weeks ago |
onryo | ba34dd4345 | 2 months ago |
jahway603 | 997af9b3c5 | 11 months ago |
jahway603 | d7de70346d | 11 months ago |
jahway603 | 6e3fb56153 | 11 months ago |
jahway603 | b14f1fc4c0 | 11 months ago |
jahway603 | 686b290ada | 11 months ago |
jahway603 | 69fdfe580b | 11 months ago |
jahway603 | d3f21bfa55 | 11 months ago |
jahway603 | 6676cd1a45 | 11 months ago |
jahway603 | 82563fd362 | 11 months ago |
jahway603 | 428e72dd8c | 11 months ago |
Duke | 957af58d8b | 12 months ago |
Duke | 336d70c088 | 12 months ago |
Duke | 1b7a8cdeb2 | 12 months ago |
Duke | 82a2a3e9a6 | 12 months ago |
Duke | 3090b635cc | 12 months ago |
Duke | f30c932603 | 12 months ago |
Duke | 108f89a6ea | 12 months ago |
Duke | 78bcb21d8c | 1 year ago |
Duke | f076ea8e52 | 1 year ago |
Duke | a5adf5ea49 | 1 year ago |
43 changed files with 381 additions and 536 deletions
@ -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 |
|||
|
@ -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") |
|||
} |
|||
} |
@ -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") |
|||
} |
|||
} |
@ -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() |
|||
} |
@ -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 |
|||
|
@ -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 |
|||
|
|||
|
@ -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 |
|||
|
@ -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 |
Loading…
Reference in new issue