diff --git a/.idea/trx.iml b/.idea/trx.iml
new file mode 100644
index 0000000..7ee078d
--- /dev/null
+++ b/.idea/trx.iml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index ed557d9..15da1fe 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,7 +4,23 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -28,13 +44,15 @@
-
+
@@ -53,8 +71,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/api/api.pb.go b/api/api.pb.go
index e8f53b4..d8aab62 100644
--- a/api/api.pb.go
+++ b/api/api.pb.go
@@ -7,7 +7,7 @@
package api
import (
- core "tron/core"
+ core "github.com/heybeachboy/trx/core"
_ "google.golang.org/genproto/googleapis/api/annotations"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
diff --git a/api/api_grpc.pb.go b/api/api_grpc.pb.go
index b8db277..2b3118e 100644
--- a/api/api_grpc.pb.go
+++ b/api/api_grpc.pb.go
@@ -8,7 +8,7 @@ package api
import (
context "context"
- core "tron/core"
+ core "github.com/heybeachboy/trx/core"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
diff --git a/api/zksnark.pb.go b/api/zksnark.pb.go
index cac92ac..6b42290 100644
--- a/api/zksnark.pb.go
+++ b/api/zksnark.pb.go
@@ -7,7 +7,7 @@
package api
import (
- core "tron/core"
+ core "github.com/heybeachboy/trx/core"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
diff --git a/go.mod b/go.mod
index 1d37c9b..ee1bcbf 100644
--- a/go.mod
+++ b/go.mod
@@ -1,30 +1,27 @@
-module tron
+module github.com/heybeachboy/trx
-go 1.20
+go 1.21.4
require (
github.com/BurntSushi/toml v1.3.2
- github.com/ethereum/go-ethereum v1.13.11
+ github.com/ethereum/go-ethereum v1.13.12
github.com/go-sql-driver/mysql v1.7.1
- github.com/mattn/go-sqlite3 v1.14.21
+ github.com/mattn/go-sqlite3 v1.14.22
github.com/semrush/zenrpc/v2 v2.1.1
github.com/shopspring/decimal v1.3.1
github.com/smirkcat/hdwallet v0.0.0-20240202015538-b4b7e122f82e
github.com/takama/daemon v1.0.0
go.uber.org/zap v1.26.0
- golang.org/x/crypto v0.18.0
- google.golang.org/genproto v0.0.0-20240125205218-1f4bbc51befe // indirect
- google.golang.org/grpc v1.61.0
+ google.golang.org/genproto/googleapis/api v0.0.0-20240213162025-012b6fc9bca9
+ google.golang.org/grpc v1.61.1
google.golang.org/protobuf v1.32.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1
- xorm.io/xorm v1.3.7
+ xorm.io/xorm v1.3.8
)
-require google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe
-
require (
github.com/beorn7/perks v1.0.1 // indirect
- github.com/bits-and-blooms/bitset v1.13.0 // indirect
+ github.com/bits-and-blooms/bitset v1.10.0 // indirect
github.com/btcsuite/btcd v0.24.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/btcsuite/btcd/btcutil v1.1.5 // indirect
@@ -36,30 +33,33 @@ require (
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/ethereum/c-kzg-4844 v0.4.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
- github.com/gofrs/uuid v4.4.0+incompatible // indirect
+ github.com/gofrs/uuid v4.2.0+incompatible // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
- github.com/gorilla/websocket v1.5.1 // indirect
+ github.com/gorilla/websocket v1.5.0 // indirect
github.com/holiman/uint256 v1.2.4 // indirect
github.com/json-iterator/go v1.1.12 // indirect
+ github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
- github.com/prometheus/client_golang v1.18.0 // indirect
- github.com/prometheus/client_model v0.5.0 // indirect
- github.com/prometheus/common v0.46.0 // indirect
- github.com/prometheus/procfs v0.12.0 // indirect
+ github.com/prometheus/client_golang v1.12.0 // indirect
+ github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a // indirect
+ github.com/prometheus/common v0.32.1 // indirect
+ github.com/prometheus/procfs v0.7.3 // indirect
github.com/shengdoushi/base58 v1.0.0 // indirect
github.com/supranational/blst v0.3.11 // indirect
- github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a // indirect
+ github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
- go.uber.org/multierr v1.11.0 // indirect
- golang.org/x/exp v0.0.0-20240119083558-1b970713d09a // indirect
+ go.uber.org/multierr v1.10.0 // indirect
+ golang.org/x/crypto v0.18.0 // indirect
+ golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
golang.org/x/net v0.20.0 // indirect
- golang.org/x/sync v0.6.0 // indirect
+ golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
- google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe // indirect
+ google.golang.org/genproto v0.0.0-20240205150955-31a09d347014 // indirect
+ google.golang.org/genproto/googleapis/rpc v0.0.0-20240205150955-31a09d347014 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
- xorm.io/builder v0.3.13 // indirect
+ xorm.io/builder v0.3.11-0.20220531020008-1bd24a7dc978 // indirect
)
diff --git a/go.sum b/go.sum
index a4e2cba..bcca41f 100644
--- a/go.sum
+++ b/go.sum
@@ -38,8 +38,11 @@ github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ=
+github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA=
+github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8=
github.com/VictoriaMetrics/fastcache v1.12.1 h1:i0mICQuojGDL3KblA7wUNlY5lOK6a4bwt3uRKnkZU40=
+github.com/VictoriaMetrics/fastcache v1.12.1/go.mod h1:tX04vaqcNoQeGLD+ra5pU5sWkuxnzWhEzLwhP9w653o=
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
@@ -50,8 +53,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
-github.com/bits-and-blooms/bitset v1.13.0 h1:bAQ9OPNFYbGHV6Nez0tmNI0RiEu7/hxlYJRUA0wFAVE=
-github.com/bits-and-blooms/bitset v1.13.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
+github.com/bits-and-blooms/bitset v1.10.0 h1:ePXTeiPEazB5+opbv5fr8umg2R/1NlzgDsyepwsSr88=
+github.com/bits-and-blooms/bitset v1.10.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M=
github.com/btcsuite/btcd v0.23.5-0.20231215221805-96c9fd8078fd/go.mod h1:nm3Bko6zh6bWP60UxwoT5LzdGJsQJaPo6HjduXq9p6A=
@@ -89,16 +92,23 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cockroachdb/errors v1.8.1 h1:A5+txlVZfOqFBDa4mGz2bUWSp0aHElvHX2bKkdbQu+Y=
+github.com/cockroachdb/errors v1.8.1/go.mod h1:qGwQn6JmZ+oMjuLwjWzUNqblqk0xl4CVV3SQbGwK7Ac=
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f h1:o/kfcElHqOiXqcou5a3rIlMc7oJbMQkeLk0VQJ7zgqY=
+github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI=
github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 h1:aPEJyR4rPBvDmeyi+l/FS/VtA00IWvjeFvjen1m1l1A=
+github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593/go.mod h1:6hk1eMY/u5t+Cf18q5lFMUA1Rc+Sm5I6Ra1QuPyxXCo=
github.com/cockroachdb/redact v1.0.8 h1:8QG/764wK+vmEYoOlfobpe12EQcS81ukx/a4hdVMxNw=
+github.com/cockroachdb/redact v1.0.8/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg=
github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2 h1:IKgmqgMQlVJIZj19CdocBeSfSaiCbEBZGKODaixqtHM=
+github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2/go.mod h1:8BT+cPK6xvFOcRlk0R8eg+OTkcqI6baNH4xAkpiYVvQ=
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo=
+github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ=
github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ=
github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI=
github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M=
github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY=
github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 h1:d28BXYi+wUpz1KBmiF9bWrjEMacUEREV6MBi2ODnrfQ=
+github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs=
github.com/crate-crypto/go-kzg-4844 v0.7.0 h1:C0vgZRk4q4EZ/JgPfzuSoxdCq3C3mOZMBShovmncxvA=
github.com/crate-crypto/go-kzg-4844 v0.7.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc=
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -107,24 +117,27 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y=
+github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0=
github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
+github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/ethereum/c-kzg-4844 v0.4.0 h1:3MS1s4JtA868KpJxroZoepdV0ZKBp3u/O5HcZ7R3nlY=
github.com/ethereum/c-kzg-4844 v0.4.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0=
-github.com/ethereum/go-ethereum v1.13.11 h1:b51Dsm+rEg7anFRUMGB8hODXHvNfcRKzz9vcj8wSdUs=
-github.com/ethereum/go-ethereum v1.13.11/go.mod h1:gFtlVORuUcT+UUIcJ/veCNjkuOSujCi338uSHJrYAew=
+github.com/ethereum/go-ethereum v1.13.12 h1:iDr9UM2JWkngBHGovRJEQn4Kor7mT4gt9rUZqB5M29Y=
+github.com/ethereum/go-ethereum v1.13.12/go.mod h1:hKL2Qcj1OvStXNSEDbucexqnEt1Wh4Cz329XsjAalZY=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
-github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU=
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
+github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 h1:BAIP2GihuqhwdILrV+7GJel5lyPV3u1+PgzrWLc0TkE=
+github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46/go.mod h1:QNpY22eby74jVhqH4WhDLDwxc/vqsern6pW+u2kbkpc=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
@@ -135,17 +148,19 @@ github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
+github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI=
github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
-github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw=
-github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA=
-github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
+github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU=
+github.com/gofrs/uuid v4.2.0+incompatible h1:yyYWMnhkhrKwwr8gAOcOCYxOOscHgDS9yZgBrnJfGa0=
+github.com/gofrs/uuid v4.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
+github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
@@ -190,6 +205,7 @@ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
+github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
@@ -200,25 +216,22 @@ github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hf
github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
-github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4=
+github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
-github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
-github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/holiman/uint256 v1.2.4 h1:jUc4Nk8fm9jZabQuqr2JzednajVmBpC+oiTiXZJEApU=
github.com/holiman/uint256 v1.2.4/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
-github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
@@ -234,28 +247,34 @@ github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfV
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
+github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
github.com/klauspost/compress v1.15.15 h1:EF27CXIuDsYJ6mmvtBRlEuB2UVOqHG1tAXgZ7yIO+lw=
+github.com/klauspost/compress v1.15.15/go.mod h1:ZcK2JAFqKOpnBlxcLsJzYfrS9X1akm9fHZNnD9+Vo/4=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
+github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
+github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
+github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c=
+github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8=
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
+github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
-github.com/mattn/go-sqlite3 v1.14.21 h1:IXocQLOykluc3xPE0Lvy8FtggMz1G+U3mEjg+0zGizc=
-github.com/mattn/go-sqlite3 v1.14.21/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
+github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
+github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
+github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI=
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
-github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
-github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY=
github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU=
github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU=
@@ -268,25 +287,20 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
+github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
-github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
-github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
+github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
+github.com/onsi/ginkgo v1.14.0 h1:2mOpI4JVVPBN+WQRa0WKH2eXR+Ey+uK4n7Zj0aYpIQA=
github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
-github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
-github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
-github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
-github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c=
github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
+github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE=
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
-github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
-github.com/onsi/gomega v1.19.0 h1:4ieX6qQjPP/BfC3mpsAtIGGlxTWPeA3Inl/7DtXw1tw=
-github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
@@ -299,41 +313,37 @@ github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP
github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
github.com/prometheus/client_golang v1.12.0 h1:C+UIj/QWtmqY13Arb8kwMt5j34/0Z2iKamrJ+ryC0Gg=
github.com/prometheus/client_golang v1.12.0/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY=
-github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk=
-github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a h1:CmF68hwI0XsOQ5UwlBopMi2Ow4Pbg32akc4KIVCOm+Y=
github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w=
-github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw=
-github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI=
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc=
github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4=
github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls=
-github.com/prometheus/common v0.46.0 h1:doXzt5ybi1HBKpsZOL0sSkaNHJJqkyfEWZGGqqScV0Y=
-github.com/prometheus/common v0.46.0/go.mod h1:Tp0qkxpb9Jsg54QMe+EAmqXkSV7Evdy1BTn+g2pa/hQ=
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU=
github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
-github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=
-github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk=
+github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
+github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/robfig/cron v1.2.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
+github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/semrush/zenrpc/v2 v2.1.1 h1:LhtvR6tkqwPUXbIfM2Qc0ouKig8h8WFcohEZ//LgG0I=
github.com/semrush/zenrpc/v2 v2.1.1/go.mod h1:+o94fyVC+TvYuT5ULLyBmql+ezicEFKtsieIXSeWBqg=
github.com/shengdoushi/base58 v1.0.0 h1:tGe4o6TmdXFJWoI31VoSWvuaKxf0Px3gqa3sUWhAxBs=
github.com/shengdoushi/base58 v1.0.0/go.mod h1:m5uIILfzcKMw6238iWAhP4l3s5+uXyF3+bJKUNhAL9I=
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU=
+github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
@@ -348,36 +358,34 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
-github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
-github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
+github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4=
github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
+github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
-github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a h1:1ur3QoCqvE5fl+nylMaIr9PVV1w343YRDtsy+Rwu7XI=
-github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48=
github.com/takama/daemon v1.0.0 h1:XS3VLnFKmqw2Z7fQ/dHRarrVjdir9G3z7BEP8osjizQ=
github.com/takama/daemon v1.0.0/go.mod h1:gKlhcjbqtBODg5v9H1nj5dU1a2j2GemtuWSNLD5rxOE=
github.com/thoas/go-funk v0.6.0/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q=
github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU=
+github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=
github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=
+github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY=
github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8=
github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
-github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk=
+go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo=
go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ=
go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
-go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
-go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo=
go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so=
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
@@ -399,8 +407,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
-golang.org/x/exp v0.0.0-20240119083558-1b970713d09a h1:Q8/wZp0KX97QFTc2ywcOE0YRjZPVIx+MXInMzdvQqcA=
-golang.org/x/exp v0.0.0-20240119083558-1b970713d09a/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08=
+golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ=
+golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
@@ -422,6 +430,7 @@ golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzB
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=
+golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -454,11 +463,7 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
-golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
-golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
-golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
-golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
@@ -475,10 +480,9 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
-golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
+golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE=
+golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -517,28 +521,20 @@ golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200722175500-76b94024e4b6/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
-golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
-golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
@@ -586,13 +582,13 @@ golang.org/x/tools v0.0.0-20200729173947-1c30660f9f89/go.mod h1:njjCfa9FT2d7l9Bc
golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
-golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
-golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc=
+golang.org/x/tools v0.15.0 h1:zdAyfUGbYmuVokhzVmghFl2ZJh5QhcfebBgmVPFYA+8=
+golang.org/x/tools v0.15.0/go.mod h1:hpksKq4dtpQWS1uQ61JkdqWM3LscIS6Slf+VVkm+wQk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
-golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8=
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
@@ -644,12 +640,12 @@ google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7Fc
google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
-google.golang.org/genproto v0.0.0-20240125205218-1f4bbc51befe h1:USL2DhxfgRchafRvt/wYyyQNzwgL7ZiURcozOE/Pkvo=
-google.golang.org/genproto v0.0.0-20240125205218-1f4bbc51befe/go.mod h1:cc8bqMqtv9gMOr0zHg2Vzff5ULhhL2IXP4sbcn32Dro=
-google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe h1:0poefMBYvYbs7g5UkjS6HcxBPaTRAmznle9jnxYoAI8=
-google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe/go.mod h1:4jWUdICTdgc3Ibxmr8nAJiiLHwQBY0UI0XZcEMaFKaA=
-google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe h1:bQnxqljG/wqi4NTXu2+DJ3n7APcEA882QZ1JvhQAq9o=
-google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe/go.mod h1:PAREbraiVEVGVdTZsVWjSbbTtSyGbAgIIvni8a8CD5s=
+google.golang.org/genproto v0.0.0-20240205150955-31a09d347014 h1:g/4bk7P6TPMkAUbUhquq98xey1slwvuVJPosdBqYJlU=
+google.golang.org/genproto v0.0.0-20240205150955-31a09d347014/go.mod h1:xEgQu1e4stdSSsxPDK8Azkrk/ECl5HvdPf6nbZrTS5M=
+google.golang.org/genproto/googleapis/api v0.0.0-20240213162025-012b6fc9bca9 h1:4++qSzdWBUy9/2x8L5KZgwZw+mjJZ2yDSCGMVM0YzRs=
+google.golang.org/genproto/googleapis/api v0.0.0-20240213162025-012b6fc9bca9/go.mod h1:PVreiBMirk8ypES6aw9d4p6iiBNSIfZEBqr3UGoAi2E=
+google.golang.org/genproto/googleapis/rpc v0.0.0-20240205150955-31a09d347014 h1:FSL3lRCkhaPFxqi0s9o+V4UI2WTzAVOvkgbd4kVV4Wg=
+google.golang.org/genproto/googleapis/rpc v0.0.0-20240205150955-31a09d347014/go.mod h1:SaPjaZGWb0lPqs6Ittu0spdfrOArqji4ZdeP5IC/9N4=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
@@ -662,8 +658,8 @@ google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKa
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
-google.golang.org/grpc v1.61.0 h1:TOvOcuXn30kRao+gfcvsebNEa5iZIiLkisYEkf7R7o0=
-google.golang.org/grpc v1.61.0/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs=
+google.golang.org/grpc v1.61.1 h1:kLAiWrZs7YeDM6MumDe7m3y4aM6wacLzM1Y/wiLP9XY=
+google.golang.org/grpc v1.61.1/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
@@ -706,15 +702,25 @@ honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
lukechampine.com/uint128 v1.2.0 h1:mBi/5l91vocEN8otkC5bDLhi2KdCticRiwbdB0O+rjI=
+lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=
modernc.org/cc/v3 v3.40.0 h1:P3g79IUS/93SYhtoeaHW+kRCIrYaxJ27MFPv+7kaTOw=
+modernc.org/cc/v3 v3.40.0/go.mod h1:/bTg4dnWkSXowUO6ssQKnOV0yMVxDYNIsIrzqTFDGH0=
modernc.org/ccgo/v3 v3.16.13 h1:Mkgdzl46i5F/CNR/Kj80Ri59hC8TKAhZrYSaqvkwzUw=
+modernc.org/ccgo/v3 v3.16.13/go.mod h1:2Quk+5YgpImhPjv2Qsob1DnZ/4som1lJTodubIcoUkY=
modernc.org/libc v1.22.2 h1:4U7v51GyhlWqQmwCHj28Rdq2Yzwk55ovjFrdPjs8Hb0=
+modernc.org/libc v1.22.2/go.mod h1:uvQavJ1pZ0hIoC/jfqNoMLURIMhKzINIWypNM17puug=
modernc.org/mathutil v1.5.0 h1:rV0Ko/6SfM+8G+yKiyI830l3Wuz1zRutdslNoQ0kfiQ=
+modernc.org/mathutil v1.5.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
modernc.org/memory v1.4.0 h1:crykUfNSnMAXaOJnnxcSzbUGMqkLWjklJKkBK2nwZwk=
+modernc.org/memory v1.4.0/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU=
modernc.org/opt v0.1.3 h1:3XOZf2yznlhC+ibLltsDGzABUGVx8J6pnFMS3E4dcq4=
+modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
modernc.org/sqlite v1.20.4 h1:J8+m2trkN+KKoE7jglyHYYYiaq5xmz2HoHJIiBlRzbE=
+modernc.org/sqlite v1.20.4/go.mod h1:zKcGyrICaxNTMEHSr1HQ2GUraP0j+845GYw37+EyT6A=
modernc.org/strutil v1.1.3 h1:fNMm+oJklMGYfU9Ylcywl0CO5O6nTfaowNsh2wpPjzY=
+modernc.org/strutil v1.1.3/go.mod h1:MEHNA7PdEnEwLvspRMtWTNnp2nnyvMfkimT1NKNAGbw=
modernc.org/token v1.0.1 h1:A3qvTqOwexpfZZeyI0FeGPDlSWX5pjZu9hF4lU+EKWg=
+modernc.org/token v1.0.1/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
@@ -722,7 +728,5 @@ rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU=
rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA=
xorm.io/builder v0.3.11-0.20220531020008-1bd24a7dc978 h1:bvLlAPW1ZMTWA32LuZMBEGHAUOcATZjzHcotf3SWweM=
xorm.io/builder v0.3.11-0.20220531020008-1bd24a7dc978/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
-xorm.io/builder v0.3.13 h1:a3jmiVVL19psGeXx8GIurTp7p0IIgqeDmwhcR6BAOAo=
-xorm.io/builder v0.3.13/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
-xorm.io/xorm v1.3.7 h1:mLceAGu0b87r9pD4qXyxGHxifOXIIrAdVcA6k95/osw=
-xorm.io/xorm v1.3.7/go.mod h1:LsCCffeeYp63ssk0pKumP6l96WZcHix7ChpurcLNuMw=
+xorm.io/xorm v1.3.8 h1:CJmplmWqfSRpLWSPMmqz+so8toBp3m7ehuRehIWedZo=
+xorm.io/xorm v1.3.8/go.mod h1:LsCCffeeYp63ssk0pKumP6l96WZcHix7ChpurcLNuMw=
diff --git a/main.go b/main.go
index 5845108..238dcd7 100644
--- a/main.go
+++ b/main.go
@@ -1,80 +1,80 @@
-package main
-
-import (
- "context"
- "fmt"
- "os"
- "time"
- "tron/daemon"
- "tron/trx"
-)
-
-const (
- // name of the service
- name = "tronrpc"
- description = "tron contract rpcservice"
-)
-
-var sigChan = make(chan os.Signal, 1) //用于系统信息接收处理的通道
-var ctx, cancel = context.WithCancel(context.Background())
-var exit = make(chan struct{}, 1)
-
-func main() {
- showVersion()
- daemon.Charge(name, description)
- preFun()
- defer sufFun()
- // 阻塞
- go daemon.HandleSystemSignal(sigChan, stop)
- <-exit
-}
-
-// go build -ldflags "-X \"main.BuildDate=%BUILD_DATE%\""
-var (
- BuildVersion string
- BuildDate string
-)
-
-// Version .
-const Version = "tronrpc version --v1.0.0"
-
-func timePrint() string {
- return time.Now().Local().Format("2006-01-02T15:04:05.000Z07:00")
-}
-
-func preFun() {
- trx.Init()
- trx.InitAllContarctServer(ctx, exit)
- fmt.Printf("tronrpc start, time=%s\n", timePrint())
-}
-
-func sufFun() {
- fmt.Printf("tronrpc exit, time=%s\n", timePrint())
-}
-
-//显示版本信息
-func showVersion() {
- if len(os.Args) < 2 {
- return
- }
- if os.Args[1] == "-v" || os.Args[1] == "-V" || os.Args[1] == "--version" || os.Args[1] == "version" {
- pintVersion()
- os.Exit(0)
- }
- return
-}
-
-func pintVersion() {
- fmt.Println(Version)
- if BuildDate != "" {
- fmt.Println("tronrpc BuildDate --" + BuildDate)
- }
- if BuildVersion != "" {
- fmt.Println("tronrpc BuildVersion --" + BuildVersion)
- }
-}
-
-func stop() {
- cancel()
- close(sigChan)
-}
+package main
+
+import (
+ "context"
+ "fmt"
+ "github.com/heybeachboy/trx/daemon"
+ "github.com/heybeachboy/trx/trx"
+ "os"
+ "time"
+)
+
+const (
+ // name of the service
+ name = "tronrpc"
+ description = "tron contract rpcservice"
+)
+
+var sigChan = make(chan os.Signal, 1) //用于系统信息接收处理的通道
+var ctx, cancel = context.WithCancel(context.Background())
+var exit = make(chan struct{}, 1)
+
+func main() {
+ showVersion()
+ daemon.Charge(name, description)
+ preFun()
+ defer sufFun()
+ // 阻塞
+ go daemon.HandleSystemSignal(sigChan, stop)
+ <-exit
+}
+
+// go build -ldflags "-X \"main.BuildDate=%BUILD_DATE%\""
+var (
+ BuildVersion string
+ BuildDate string
+)
+
+// Version .
+const Version = "tronrpc version --v1.0.0"
+
+func timePrint() string {
+ return time.Now().Local().Format("2006-01-02T15:04:05.000Z07:00")
+}
+
+func preFun() {
+ trx.Init()
+ trx.InitAllContarctServer(ctx, exit)
+ fmt.Printf("tronrpc start, time=%s\n", timePrint())
+}
+
+func sufFun() {
+ fmt.Printf("tronrpc exit, time=%s\n", timePrint())
+}
+
+//显示版本信息
+func showVersion() {
+ if len(os.Args) < 2 {
+ return
+ }
+ if os.Args[1] == "-v" || os.Args[1] == "-V" || os.Args[1] == "--version" || os.Args[1] == "version" {
+ pintVersion()
+ os.Exit(0)
+ }
+ return
+}
+
+func pintVersion() {
+ fmt.Println(Version)
+ if BuildDate != "" {
+ fmt.Println("tronrpc BuildDate --" + BuildDate)
+ }
+ if BuildVersion != "" {
+ fmt.Println("tronrpc BuildVersion --" + BuildVersion)
+ }
+}
+
+func stop() {
+ cancel()
+ close(sigChan)
+}
diff --git a/service/client.go b/service/client.go
index 0df3ef2..989ff22 100644
--- a/service/client.go
+++ b/service/client.go
@@ -4,12 +4,12 @@ import (
"context"
"crypto/ecdsa"
"fmt"
+ "github.com/heybeachboy/trx/api"
+ "github.com/heybeachboy/trx/core"
+ "github.com/heybeachboy/trx/hexutil"
+ "github.com/heybeachboy/trx/util"
"strconv"
"time"
- "tron/api"
- "tron/core"
- "tron/hexutil"
- "tron/util"
"github.com/smirkcat/hdwallet"
diff --git a/trx/address.go b/trx/address.go
index 000d8db..5d31b71 100644
--- a/trx/address.go
+++ b/trx/address.go
@@ -1,44 +1,44 @@
-package trx
-
-import (
- "crypto/ecdsa"
- "errors"
- "tron/model"
-
- "github.com/smirkcat/hdwallet"
-)
-
-func SearchAccount(addr string) (*Account, error) {
- var ac *Account
- var err error
- if IsMulti {
- acmuti, err := model.GetUsedOfAddressMulti("tron", addr)
- if err != nil || acmuti.Id < 1 {
- return nil, err
- }
- ac = &Account{
- Address: acmuti.TronAddress,
- PublicKey: acmuti.PublicKey,
- PrivateKey: acmuti.PrivateKey,
- User: acmuti.Account,
- }
- return ac, nil
- }
- ac, err = dbengine.GetAccountWithAddr(addr)
- return ac, err
-}
-
-func InitAddressDB(dsn string) {
- if IsMulti {
- model.InitDB(dsn)
- }
-}
-
-func NewPrivateKey() (int, *ecdsa.PrivateKey, error) {
- if IsMulti {
- return 0, nil, errors.New("not suppot new addr is_multi true ")
- }
- index := dbengine.GetAccountMaxIndex() + 1
- ac, err := hdwallet.NewPrivateKeyIndex(index)
- return index, ac, err
-}
+package trx
+
+import (
+ "crypto/ecdsa"
+ "errors"
+ "github.com/heybeachboy/trx/model"
+
+ "github.com/smirkcat/hdwallet"
+)
+
+func SearchAccount(addr string) (*Account, error) {
+ var ac *Account
+ var err error
+ if IsMulti {
+ acmuti, err := model.GetUsedOfAddressMulti("tron", addr)
+ if err != nil || acmuti.Id < 1 {
+ return nil, err
+ }
+ ac = &Account{
+ Address: acmuti.TronAddress,
+ PublicKey: acmuti.PublicKey,
+ PrivateKey: acmuti.PrivateKey,
+ User: acmuti.Account,
+ }
+ return ac, nil
+ }
+ ac, err = dbengine.GetAccountWithAddr(addr)
+ return ac, err
+}
+
+func InitAddressDB(dsn string) {
+ if IsMulti {
+ model.InitDB(dsn)
+ }
+}
+
+func NewPrivateKey() (int, *ecdsa.PrivateKey, error) {
+ if IsMulti {
+ return 0, nil, errors.New("not suppot new addr is_multi true ")
+ }
+ index := dbengine.GetAccountMaxIndex() + 1
+ ac, err := hdwallet.NewPrivateKeyIndex(index)
+ return index, ac, err
+}
diff --git a/trx/client.go b/trx/client.go
index b86b970..603df8a 100644
--- a/trx/client.go
+++ b/trx/client.go
@@ -1,335 +1,335 @@
-package trx
-
-import (
- "crypto/ecdsa"
- "encoding/json"
- "fmt"
- "math/rand"
- "strconv"
- "strings"
- "sync"
- "time"
- "tron/log"
- "tron/service"
-
- "github.com/smirkcat/hdwallet"
-
- wallet "tron/util"
-
- "github.com/shopspring/decimal"
-)
-
-var nodeall []string
-var nodemain string
-
-var mapContract = make(map[string]*Contract)
-var mapContractType = map[string]bool{
- "trx": true,
- "trc10": true,
- "trc20": true,
-}
-
-var walletInfo = wallet.Info{
- ContractBalance: make(map[string]json.Number),
-}
-var lockInfo sync.RWMutex
-
-const (
- Trx string = "trx"
- Trc10 string = "trc10"
- Trc20 string = "trc20"
-)
-
-// InitContract 初始化所有合约
-func InitContract(contracts []Contract) {
- for i, v := range contracts {
- if ok := mapContractType[v.Type]; ok {
- mapContract[v.Contract] = &contracts[i]
- } else {
- panic(fmt.Errorf("the contract type %s is not exist pleasecheck", v.Type))
- }
- }
-}
-
-func InitMainNode(url string) {
- nodemain = url
- nodeall = make([]string, 1)
- nodeall[0] = url
-}
-
-func InitAllNode(url []string) {
- nodeall = append(nodeall, url...)
-}
-
-func newGrpcClient(url string) *service.GrpcClient {
- return service.NewGrpcClient(url)
-}
-
-// 后期改为 长链接
-func getMaineNode() *service.GrpcClient {
- node := newGrpcClient(nodemain)
- err := node.Start()
- if err != nil {
- log.Errorf("main node %s err %s", nodemain, err.Error())
- }
- return node
-}
-
-// GenerateRandomNumber 生成count个[start,end)结束的不重复的随机数 为了用户抽奖 TODO
-func GenerateRandomNumber(start int, end int, count int) []int {
- //范围检查
- if end < start || (end-start) < count {
- return nil
- }
- //存放结果的slice
- nums := make([]int, 0)
- //随机数生成器,加入时间戳保证每次生成的随机数不一样
- r := rand.New(rand.NewSource(time.Now().UnixNano()))
- for len(nums) < count {
- //生成随机数
- num := r.Intn((end - start)) + start
-
- //查重
- exist := false
- for _, v := range nums {
- if v == num {
- exist = true
- break
- }
- }
-
- if !exist {
- nums = append(nums, num)
- }
- }
- return nums
-}
-
-func init() {
- rand.Seed(time.Now().UnixNano())
-}
-
-func getRandOneNode() *service.GrpcClient {
- lens := len(nodeall)
- for i := 0; i < lens; i++ {
- nodeurl := nodeall[rand.Intn(lens)]
- node := newGrpcClient(nodeurl)
- err := node.Start()
- if err != nil {
- log.Errorf("node %s err %s", nodeurl, err.Error())
- continue
- }
- return node
- }
- log.Warn("use main node")
- return getMaineNode()
-}
-
-// 判断当前属于什么合约
-func chargeContract(contract string) (string, int32) {
- if contract == "trx" || contract == "" {
- return Trx, trxdecimal
- }
- if v := mapContract[contract]; v != nil {
- if ok := mapContractType[v.Type]; ok {
- return v.Type, v.Decimal
- }
- }
- return "NONE", 18
-}
-
-// IsContract 判断当前合约是否存在
-func IsContract(contract string) bool {
- if contract == "trx" || contract == "" {
- return true
- }
- if v := mapContract[contract]; v != nil {
- if ok := mapContractType[v.Type]; ok {
- return true
- }
- }
- return false
-}
-
-// GetWalletInfo 钱包信息
-func getWalletInfoContract(contract string) wallet.Info {
- var info = walletInfo
- if contract != Trx {
- lockInfo.RLock()
- if v, ok := walletInfo.ContractBalance[contract]; ok {
- info.Balance = v
- } else {
- info.Balance = json.Number("0")
- }
- lockInfo.RUnlock()
- }
- return info
-}
-
-func processBlockHeight(block string) int64 {
- num := strings.Split(block, ",")[0]
- heights := strings.Split(num, ":")
- if len(heights) < 1 {
- return 0
- }
- height, _ := strconv.ParseInt(heights[1], 10, 64)
- return height
-}
-
-// GetWalletInfo 钱包信息
-func getWalletInfo() (err error) {
- node := getMaineNode()
- defer node.Conn.Close()
- re, err1 := node.GetNodeInfo()
- if err1 != nil {
- err = err1
- } else {
- tmp := processBlockHeight(re.Block)
- if tmp > 0 {
- blockHeightTop = tmp
- } else {
- blockHeightTop = re.BeginSyncNum
- }
- walletInfo.BlockHeight = blockHeightTop
- walletInfo.Blocks = targetHeight
- walletInfo.Connections = int64(re.CurrentConnectCount)
- walletInfo.Difficulty = re.TotalFlow
- }
- ac, err1 := node.GetAccount(mainAddr)
- lockInfo.Lock()
- if err1 != nil {
- if err != nil {
- err = fmt.Errorf("node: %s balance: %s", err, err1)
- } else {
- err = err1
- }
- } else {
- walletInfo.Balance = json.Number(decimal.New(ac.Balance, -6).String())
- for _, v := range mapContract {
- if v.Type == Trc10 && ac.AssetV2 != nil {
- if vv, ok := ac.AssetV2[v.Contract]; ok {
- walletInfo.ContractBalance[v.Contract] = json.Number(decimal.New(vv, -v.Decimal).String())
- continue
- }
- }
- }
- }
-
- for _, v := range mapContract {
- if v.Type != Trc20 {
- continue
- }
- re, err := node.GetConstantResultOfContract(mainAccout, v.Contract, processBalanceOfParameter(mainAddr))
- if err != nil || len(re) < 1 {
- continue
- }
- walletInfo.ContractBalance[v.Contract] = json.Number(decimal.New(processBalanceOfData(re[0]), -v.Decimal).String())
- }
- lockInfo.Unlock()
- return
-}
-
-// 获取余额
-func getBalanceByAddress(contract, addr string) (decimal.Decimal, error) {
- typs, decimalnum := chargeContract(contract)
- if typs == Trc20 {
- balance, err := getTrc20BalanceByAddress(contract, addr, mainAccout)
- return decimal.New(balance, -decimalnum), err
- }
- node := getMaineNode()
- defer node.Conn.Close()
- ac, err := node.GetAccount(addr)
- if err != nil {
- return decimal.Zero, err
- }
- switch typs {
- case Trx:
- return decimal.New(ac.Balance, -decimalnum), err
- case Trc10:
- if ac.AssetV2 != nil {
- if v, ok := ac.AssetV2[contract]; ok {
- return decimal.New(v, -decimalnum), err
- }
- }
- }
- return decimal.Zero, nil
-}
-
-func getTrc20BalanceByAddress(contract, addr string, ac *ecdsa.PrivateKey) (int64, error) {
- node := getMaineNode()
- defer node.Conn.Close()
- re, err := node.GetConstantResultOfContract(ac, contract, processBalanceOfParameter(addr))
- if err != nil || len(re) < 1 {
- return 0, err
- }
- return processBalanceOfData(re[0]), nil
-}
-
-func getlastBlock() int64 {
- if minScanBlock < 0 {
- return -minScanBlock
- }
- tmp := minScanBlock
- block, err := dbengine.LoadLastBlockHeight()
- if err != nil || block < tmp {
- block = tmp
- }
- return block
-}
-
-func validaddress(addr string) bool {
- if len(addr) != 34 {
- return false
- }
- if string(addr[0:1]) != "T" {
- return false
- }
- _, err := hdwallet.DecodeCheck(addr)
- return err == nil
-}
-
-func loadAccountWithUUID(pri, uuid string) (*ecdsa.PrivateKey, error) {
- pwd := hdwallet.HashAndSalt([]byte(uuid))
- return hdwallet.LoadPrivateKeyFromDecrypt(pri, pwd)
-}
-
-func loadAccount(addr string) (*ecdsa.PrivateKey, error) {
- re, err := SearchAccount(addr)
- if err != nil {
- return nil, err
- }
- if re == nil {
- return nil, fmt.Errorf("adderss %s is not exist", addr)
- }
- var pwd string
- if re.User != "" {
- pwd = hdwallet.HashAndSalt([]byte(re.User))
- return hdwallet.LoadPrivateKeyFromDecrypt(re.PrivateKey, pwd)
- }
- return hdwallet.GetPrivateKeyByHexString(re.PrivateKey)
-}
-
-func creataddress() (*Account, error) {
- var uuidv4 = hdwallet.GenPwd()
- pwd := hdwallet.HashAndSalt([]byte(uuidv4))
- index, privateKey, err := NewPrivateKey()
- if err != nil {
- return nil, err
- }
- adderss := hdwallet.PrikeyToAddressTron(privateKey)
- priEncrypt, err := hdwallet.StorePrivateKeyToDecrypt(privateKey, pwd)
- if err != nil {
- return nil, err
- }
- accountT := &Account{
- Address: adderss,
- Index: index,
- PrivateKey: priEncrypt,
- PublicKey: hdwallet.PubkeyToHexString(privateKey.Public().(*ecdsa.PublicKey)),
- User: uuidv4,
- Ctime: time.Now().Unix(),
- Amount: 0,
- }
- _, err = dbengine.InsertAccount(accountT)
- return accountT, err
-}
+package trx
+
+import (
+ "crypto/ecdsa"
+ "encoding/json"
+ "fmt"
+ "github.com/heybeachboy/trx/log"
+ "github.com/heybeachboy/trx/service"
+ "math/rand"
+ "strconv"
+ "strings"
+ "sync"
+ "time"
+
+ "github.com/smirkcat/hdwallet"
+
+ wallet "github.com/heybeachboy/trx/util"
+
+ "github.com/shopspring/decimal"
+)
+
+var nodeall []string
+var nodemain string
+
+var mapContract = make(map[string]*Contract)
+var mapContractType = map[string]bool{
+ "trx": true,
+ "trc10": true,
+ "trc20": true,
+}
+
+var walletInfo = wallet.Info{
+ ContractBalance: make(map[string]json.Number),
+}
+var lockInfo sync.RWMutex
+
+const (
+ Trx string = "trx"
+ Trc10 string = "trc10"
+ Trc20 string = "trc20"
+)
+
+// InitContract 初始化所有合约
+func InitContract(contracts []Contract) {
+ for i, v := range contracts {
+ if ok := mapContractType[v.Type]; ok {
+ mapContract[v.Contract] = &contracts[i]
+ } else {
+ panic(fmt.Errorf("the contract type %s is not exist pleasecheck", v.Type))
+ }
+ }
+}
+
+func InitMainNode(url string) {
+ nodemain = url
+ nodeall = make([]string, 1)
+ nodeall[0] = url
+}
+
+func InitAllNode(url []string) {
+ nodeall = append(nodeall, url...)
+}
+
+func newGrpcClient(url string) *service.GrpcClient {
+ return service.NewGrpcClient(url)
+}
+
+// 后期改为 长链接
+func getMaineNode() *service.GrpcClient {
+ node := newGrpcClient(nodemain)
+ err := node.Start()
+ if err != nil {
+ log.Errorf("main node %s err %s", nodemain, err.Error())
+ }
+ return node
+}
+
+// GenerateRandomNumber 生成count个[start,end)结束的不重复的随机数 为了用户抽奖 TODO
+func GenerateRandomNumber(start int, end int, count int) []int {
+ //范围检查
+ if end < start || (end-start) < count {
+ return nil
+ }
+ //存放结果的slice
+ nums := make([]int, 0)
+ //随机数生成器,加入时间戳保证每次生成的随机数不一样
+ r := rand.New(rand.NewSource(time.Now().UnixNano()))
+ for len(nums) < count {
+ //生成随机数
+ num := r.Intn((end - start)) + start
+
+ //查重
+ exist := false
+ for _, v := range nums {
+ if v == num {
+ exist = true
+ break
+ }
+ }
+
+ if !exist {
+ nums = append(nums, num)
+ }
+ }
+ return nums
+}
+
+func init() {
+ rand.Seed(time.Now().UnixNano())
+}
+
+func getRandOneNode() *service.GrpcClient {
+ lens := len(nodeall)
+ for i := 0; i < lens; i++ {
+ nodeurl := nodeall[rand.Intn(lens)]
+ node := newGrpcClient(nodeurl)
+ err := node.Start()
+ if err != nil {
+ log.Errorf("node %s err %s", nodeurl, err.Error())
+ continue
+ }
+ return node
+ }
+ log.Warn("use main node")
+ return getMaineNode()
+}
+
+// 判断当前属于什么合约
+func chargeContract(contract string) (string, int32) {
+ if contract == "trx" || contract == "" {
+ return Trx, trxdecimal
+ }
+ if v := mapContract[contract]; v != nil {
+ if ok := mapContractType[v.Type]; ok {
+ return v.Type, v.Decimal
+ }
+ }
+ return "NONE", 18
+}
+
+// IsContract 判断当前合约是否存在
+func IsContract(contract string) bool {
+ if contract == "trx" || contract == "" {
+ return true
+ }
+ if v := mapContract[contract]; v != nil {
+ if ok := mapContractType[v.Type]; ok {
+ return true
+ }
+ }
+ return false
+}
+
+// GetWalletInfo 钱包信息
+func getWalletInfoContract(contract string) wallet.Info {
+ var info = walletInfo
+ if contract != Trx {
+ lockInfo.RLock()
+ if v, ok := walletInfo.ContractBalance[contract]; ok {
+ info.Balance = v
+ } else {
+ info.Balance = json.Number("0")
+ }
+ lockInfo.RUnlock()
+ }
+ return info
+}
+
+func processBlockHeight(block string) int64 {
+ num := strings.Split(block, ",")[0]
+ heights := strings.Split(num, ":")
+ if len(heights) < 1 {
+ return 0
+ }
+ height, _ := strconv.ParseInt(heights[1], 10, 64)
+ return height
+}
+
+// GetWalletInfo 钱包信息
+func getWalletInfo() (err error) {
+ node := getMaineNode()
+ defer node.Conn.Close()
+ re, err1 := node.GetNodeInfo()
+ if err1 != nil {
+ err = err1
+ } else {
+ tmp := processBlockHeight(re.Block)
+ if tmp > 0 {
+ blockHeightTop = tmp
+ } else {
+ blockHeightTop = re.BeginSyncNum
+ }
+ walletInfo.BlockHeight = blockHeightTop
+ walletInfo.Blocks = targetHeight
+ walletInfo.Connections = int64(re.CurrentConnectCount)
+ walletInfo.Difficulty = re.TotalFlow
+ }
+ ac, err1 := node.GetAccount(mainAddr)
+ lockInfo.Lock()
+ if err1 != nil {
+ if err != nil {
+ err = fmt.Errorf("node: %s balance: %s", err, err1)
+ } else {
+ err = err1
+ }
+ } else {
+ walletInfo.Balance = json.Number(decimal.New(ac.Balance, -6).String())
+ for _, v := range mapContract {
+ if v.Type == Trc10 && ac.AssetV2 != nil {
+ if vv, ok := ac.AssetV2[v.Contract]; ok {
+ walletInfo.ContractBalance[v.Contract] = json.Number(decimal.New(vv, -v.Decimal).String())
+ continue
+ }
+ }
+ }
+ }
+
+ for _, v := range mapContract {
+ if v.Type != Trc20 {
+ continue
+ }
+ re, err := node.GetConstantResultOfContract(mainAccout, v.Contract, processBalanceOfParameter(mainAddr))
+ if err != nil || len(re) < 1 {
+ continue
+ }
+ walletInfo.ContractBalance[v.Contract] = json.Number(decimal.New(processBalanceOfData(re[0]), -v.Decimal).String())
+ }
+ lockInfo.Unlock()
+ return
+}
+
+// 获取余额
+func getBalanceByAddress(contract, addr string) (decimal.Decimal, error) {
+ typs, decimalnum := chargeContract(contract)
+ if typs == Trc20 {
+ balance, err := getTrc20BalanceByAddress(contract, addr, mainAccout)
+ return decimal.New(balance, -decimalnum), err
+ }
+ node := getMaineNode()
+ defer node.Conn.Close()
+ ac, err := node.GetAccount(addr)
+ if err != nil {
+ return decimal.Zero, err
+ }
+ switch typs {
+ case Trx:
+ return decimal.New(ac.Balance, -decimalnum), err
+ case Trc10:
+ if ac.AssetV2 != nil {
+ if v, ok := ac.AssetV2[contract]; ok {
+ return decimal.New(v, -decimalnum), err
+ }
+ }
+ }
+ return decimal.Zero, nil
+}
+
+func getTrc20BalanceByAddress(contract, addr string, ac *ecdsa.PrivateKey) (int64, error) {
+ node := getMaineNode()
+ defer node.Conn.Close()
+ re, err := node.GetConstantResultOfContract(ac, contract, processBalanceOfParameter(addr))
+ if err != nil || len(re) < 1 {
+ return 0, err
+ }
+ return processBalanceOfData(re[0]), nil
+}
+
+func getlastBlock() int64 {
+ if minScanBlock < 0 {
+ return -minScanBlock
+ }
+ tmp := minScanBlock
+ block, err := dbengine.LoadLastBlockHeight()
+ if err != nil || block < tmp {
+ block = tmp
+ }
+ return block
+}
+
+func validaddress(addr string) bool {
+ if len(addr) != 34 {
+ return false
+ }
+ if string(addr[0:1]) != "T" {
+ return false
+ }
+ _, err := hdwallet.DecodeCheck(addr)
+ return err == nil
+}
+
+func loadAccountWithUUID(pri, uuid string) (*ecdsa.PrivateKey, error) {
+ pwd := hdwallet.HashAndSalt([]byte(uuid))
+ return hdwallet.LoadPrivateKeyFromDecrypt(pri, pwd)
+}
+
+func loadAccount(addr string) (*ecdsa.PrivateKey, error) {
+ re, err := SearchAccount(addr)
+ if err != nil {
+ return nil, err
+ }
+ if re == nil {
+ return nil, fmt.Errorf("adderss %s is not exist", addr)
+ }
+ var pwd string
+ if re.User != "" {
+ pwd = hdwallet.HashAndSalt([]byte(re.User))
+ return hdwallet.LoadPrivateKeyFromDecrypt(re.PrivateKey, pwd)
+ }
+ return hdwallet.GetPrivateKeyByHexString(re.PrivateKey)
+}
+
+func creataddress() (*Account, error) {
+ var uuidv4 = hdwallet.GenPwd()
+ pwd := hdwallet.HashAndSalt([]byte(uuidv4))
+ index, privateKey, err := NewPrivateKey()
+ if err != nil {
+ return nil, err
+ }
+ adderss := hdwallet.PrikeyToAddressTron(privateKey)
+ priEncrypt, err := hdwallet.StorePrivateKeyToDecrypt(privateKey, pwd)
+ if err != nil {
+ return nil, err
+ }
+ accountT := &Account{
+ Address: adderss,
+ Index: index,
+ PrivateKey: priEncrypt,
+ PublicKey: hdwallet.PubkeyToHexString(privateKey.Public().(*ecdsa.PublicKey)),
+ User: uuidv4,
+ Ctime: time.Now().Unix(),
+ Amount: 0,
+ }
+ _, err = dbengine.InsertAccount(accountT)
+ return accountT, err
+}
diff --git a/trx/init.go b/trx/init.go
index 803a9a0..44b6d2c 100644
--- a/trx/init.go
+++ b/trx/init.go
@@ -1,215 +1,215 @@
-package trx
-
-import (
- "context"
- "crypto/ecdsa"
- "os"
- "path/filepath"
- "strings"
- "sync"
- "time"
-
- "tron/log"
-
- "github.com/BurntSushi/toml"
- "github.com/shopspring/decimal"
- "github.com/smirkcat/hdwallet"
-)
-
-var ctx, canceltask = context.WithCancel(context.Background())
-var wg sync.WaitGroup
-
-var port = "8245"
-var trxdecimal int32 = 6
-
-var IsMulti bool // 是否采用外部多链地址
-
-var minScanBlock int64 = 58737696 // 最小 扫描高度
-var targetHeight int64
-var blockHeightTop int64
-var minAmount decimal.Decimal
-var remainAmount = decimal.New(10, 0) // 保留10个
-
-var goroutineNumScan int64 = 4 // 扫描交易记录的并发携程数
-
-var mainAddr = "" // 主地址
-var mainAccout *ecdsa.PrivateKey // 主地址密钥
-
-// 归集参数
-var minFee = decimal.New(5, 0) // 每个地址至少保留多少trx手续费
-var perFee = decimal.New(10, 0) // 每次归集每个合约需要手续费消耗
-
-var dbengine *DB // 数据库连接
-
-var globalConf GlobalConf
-
-var curr = getCurrentDirectory() + `/`
-
-func getCurrentDirectory() string {
- dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
- if err != nil {
- return "."
- }
- return strings.Replace(dir, "\\", "/", -1)
-}
-
-func InitSeed() {
- if globalConf.Seed != "" {
- hdwallet.Decrypt(globalConf.Seed, globalConf.SeedPri)
- hdwallet.InitHdwallet(globalConf.Seed)
- }
-}
-
-// InitLog 初始化日志文件
-func InitLog() {
- var logConfigInfoName, logConfigErrorName, logLevel string
- logConfigInfoName = curr + "tron.log"
- logConfigErrorName = curr + "tron-err.log"
- logLevel = globalConf.LogLevel
- log.Init(logConfigInfoName, logConfigErrorName, logLevel)
-}
-
-func InitConfig() {
- if _, err := toml.DecodeFile(curr+"tron.toml", &globalConf); err != nil {
- panic(err)
- }
- if globalConf.Client.Port != "" {
- port = globalConf.Client.Port
- }
-
- IsMulti = globalConf.IsMulti
-
- minAmount = globalConf.Collection.MinAmount
-
- minScanBlock = globalConf.Scantraderecord.MinScanBlock
-
- if globalConf.Scantraderecord.GoroutineNum > 0 {
- goroutineNumScan = globalConf.Scantraderecord.GoroutineNum
- }
-
- if globalConf.Client.Count > 0 && globalConf.Client.Count < 100 {
- count = globalConf.Client.Count
- }
- // 最大100trx
- if globalConf.Client.Feelimit > 0 && globalConf.Client.Feelimit < 100000000 {
- feelimit = globalConf.Client.Feelimit
- }
-
- if globalConf.Client.MinFee.Cmp(decimal.Zero) > 0 {
- minFee = globalConf.Client.MinFee
- }
-
- if globalConf.Client.PerFee.Cmp(decimal.Zero) > 0 {
- perFee = globalConf.Client.PerFee
- }
-}
-
-func InitDB() {
- var err error
- dbengine, err = NewDB(globalConf.Client.DBAddr)
- if err != nil {
- panic(err)
- }
- err = dbengine.Sync()
- if err != nil {
- panic(err)
- }
- InitAddressDB(globalConf.Client.DBAddrMulti)
-}
-
-// InitMainAndFee 初始化主账户和手续费账户
-func InitMainAndFee() {
- var err error
- mainAddr = globalConf.Client.MainAddr
- mainAccout, err = loadAccountWithUUID(globalConf.Client.MainPri, globalConf.Client.Password)
- if err != nil {
- panic(err)
- }
-}
-
-// InitWalletInfo 初始化钱包信息
-func InitWalletInfo() {
- targetHeight = getlastBlock()
- log.Info("lastblock:", targetHeight)
- err := getWalletInfo()
- if err != nil {
- panic(err)
- }
- log.Info("walletInfo:", walletInfo)
-}
-
-// Init 初始化
-func Init() {
- InitConfig()
- InitLog() // 首先初始化日志
- InitDB()
- InitMainNode(globalConf.Client.NodeTrx)
- InitAllNode(globalConf.Client.NodeUrl)
- InitContract(globalConf.Contracts)
- InitMainAndFee()
- InitWalletInfo()
- InitSeed()
- task()
-}
-
-func task() {
- var scanT = globalConf.Scantraderecord.TimeIntervalSec
- if scanT < 1 {
- scanT = 60
- }
- var collectT = globalConf.Collection.TimeIntervalMin
- if collectT < 1 {
- collectT = 30
- }
- var timed = time.Duration(scanT) * time.Second
- var timec = time.Duration(collectT) * time.Minute
- tiker := time.NewTicker(timed)
- tikerT := time.NewTicker(2 * timed)
- tikerC := time.NewTicker(timec)
- wg.Add(3)
- go func() {
- log.Info("RunTransaction Ticker")
- for {
- select {
- case <-ctx.Done():
- wg.Done()
- tiker.Stop()
- return
- case <-tiker.C:
- log.Debug("start RunTransaction")
- RunTransaction()
- log.Debug("stop RunTransaction")
- }
- }
- }()
- go func() {
- log.Info("getWalletInfo Ticker")
- for {
- select {
- case <-ctx.Done():
- wg.Done()
- tikerT.Stop()
- return
- case <-tikerT.C:
- log.Debug("start getWalletInfo")
- getWalletInfo()
- log.Debug("stop getWalletInfo")
- }
- }
- }()
- go func() {
- log.Info("RunCollect Ticker")
- for {
- select {
- case <-ctx.Done():
- wg.Done()
- tikerC.Stop()
- return
- case <-tikerC.C:
- log.Debug("start RunCollect")
- RunCollect()
- log.Debug("stop RunCollect")
- }
- }
- }()
-}
+package trx
+
+import (
+ "context"
+ "crypto/ecdsa"
+ "os"
+ "path/filepath"
+ "strings"
+ "sync"
+ "time"
+
+ "github.com/heybeachboy/trx/log"
+
+ "github.com/BurntSushi/toml"
+ "github.com/shopspring/decimal"
+ "github.com/smirkcat/hdwallet"
+)
+
+var ctx, canceltask = context.WithCancel(context.Background())
+var wg sync.WaitGroup
+
+var port = "8245"
+var trxdecimal int32 = 6
+
+var IsMulti bool // 是否采用外部多链地址
+
+var minScanBlock int64 = 58737696 // 最小 扫描高度
+var targetHeight int64
+var blockHeightTop int64
+var minAmount decimal.Decimal
+var remainAmount = decimal.New(10, 0) // 保留10个
+
+var goroutineNumScan int64 = 4 // 扫描交易记录的并发携程数
+
+var mainAddr = "" // 主地址
+var mainAccout *ecdsa.PrivateKey // 主地址密钥
+
+// 归集参数
+var minFee = decimal.New(5, 0) // 每个地址至少保留多少trx手续费
+var perFee = decimal.New(10, 0) // 每次归集每个合约需要手续费消耗
+
+var dbengine *DB // 数据库连接
+
+var globalConf GlobalConf
+
+var curr = getCurrentDirectory() + `/`
+
+func getCurrentDirectory() string {
+ dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
+ if err != nil {
+ return "."
+ }
+ return strings.Replace(dir, "\\", "/", -1)
+}
+
+func InitSeed() {
+ if globalConf.Seed != "" {
+ hdwallet.Decrypt(globalConf.Seed, globalConf.SeedPri)
+ hdwallet.InitHdwallet(globalConf.Seed)
+ }
+}
+
+// InitLog 初始化日志文件
+func InitLog() {
+ var logConfigInfoName, logConfigErrorName, logLevel string
+ logConfigInfoName = curr + "tron.log"
+ logConfigErrorName = curr + "tron-err.log"
+ logLevel = globalConf.LogLevel
+ log.Init(logConfigInfoName, logConfigErrorName, logLevel)
+}
+
+func InitConfig() {
+ if _, err := toml.DecodeFile(curr+"tron.toml", &globalConf); err != nil {
+ panic(err)
+ }
+ if globalConf.Client.Port != "" {
+ port = globalConf.Client.Port
+ }
+
+ IsMulti = globalConf.IsMulti
+
+ minAmount = globalConf.Collection.MinAmount
+
+ minScanBlock = globalConf.Scantraderecord.MinScanBlock
+
+ if globalConf.Scantraderecord.GoroutineNum > 0 {
+ goroutineNumScan = globalConf.Scantraderecord.GoroutineNum
+ }
+
+ if globalConf.Client.Count > 0 && globalConf.Client.Count < 100 {
+ count = globalConf.Client.Count
+ }
+ // 最大100trx
+ if globalConf.Client.Feelimit > 0 && globalConf.Client.Feelimit < 100000000 {
+ feelimit = globalConf.Client.Feelimit
+ }
+
+ if globalConf.Client.MinFee.Cmp(decimal.Zero) > 0 {
+ minFee = globalConf.Client.MinFee
+ }
+
+ if globalConf.Client.PerFee.Cmp(decimal.Zero) > 0 {
+ perFee = globalConf.Client.PerFee
+ }
+}
+
+func InitDB() {
+ var err error
+ dbengine, err = NewDB(globalConf.Client.DBAddr)
+ if err != nil {
+ panic(err)
+ }
+ err = dbengine.Sync()
+ if err != nil {
+ panic(err)
+ }
+ InitAddressDB(globalConf.Client.DBAddrMulti)
+}
+
+// InitMainAndFee 初始化主账户和手续费账户
+func InitMainAndFee() {
+ var err error
+ mainAddr = globalConf.Client.MainAddr
+ mainAccout, err = loadAccountWithUUID(globalConf.Client.MainPri, globalConf.Client.Password)
+ if err != nil {
+ panic(err)
+ }
+}
+
+// InitWalletInfo 初始化钱包信息
+func InitWalletInfo() {
+ targetHeight = getlastBlock()
+ log.Info("lastblock:", targetHeight)
+ err := getWalletInfo()
+ if err != nil {
+ panic(err)
+ }
+ log.Info("walletInfo:", walletInfo)
+}
+
+// Init 初始化
+func Init() {
+ InitConfig()
+ InitLog() // 首先初始化日志
+ InitDB()
+ InitMainNode(globalConf.Client.NodeTrx)
+ InitAllNode(globalConf.Client.NodeUrl)
+ InitContract(globalConf.Contracts)
+ InitMainAndFee()
+ InitWalletInfo()
+ InitSeed()
+ task()
+}
+
+func task() {
+ var scanT = globalConf.Scantraderecord.TimeIntervalSec
+ if scanT < 1 {
+ scanT = 60
+ }
+ var collectT = globalConf.Collection.TimeIntervalMin
+ if collectT < 1 {
+ collectT = 30
+ }
+ var timed = time.Duration(scanT) * time.Second
+ var timec = time.Duration(collectT) * time.Minute
+ tiker := time.NewTicker(timed)
+ tikerT := time.NewTicker(2 * timed)
+ tikerC := time.NewTicker(timec)
+ wg.Add(3)
+ go func() {
+ log.Info("RunTransaction Ticker")
+ for {
+ select {
+ case <-ctx.Done():
+ wg.Done()
+ tiker.Stop()
+ return
+ case <-tiker.C:
+ log.Debug("start RunTransaction")
+ RunTransaction()
+ log.Debug("stop RunTransaction")
+ }
+ }
+ }()
+ go func() {
+ log.Info("getWalletInfo Ticker")
+ for {
+ select {
+ case <-ctx.Done():
+ wg.Done()
+ tikerT.Stop()
+ return
+ case <-tikerT.C:
+ log.Debug("start getWalletInfo")
+ getWalletInfo()
+ log.Debug("stop getWalletInfo")
+ }
+ }
+ }()
+ go func() {
+ log.Info("RunCollect Ticker")
+ for {
+ select {
+ case <-ctx.Done():
+ wg.Done()
+ tikerC.Stop()
+ return
+ case <-tikerC.C:
+ log.Debug("start RunCollect")
+ RunCollect()
+ log.Debug("stop RunCollect")
+ }
+ }
+ }()
+}
diff --git a/trx/server.go b/trx/server.go
index 0184b82..e2a826a 100644
--- a/trx/server.go
+++ b/trx/server.go
@@ -1,104 +1,105 @@
-package trx
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "tron/util"
-
- "github.com/semrush/zenrpc/v2"
- "github.com/shopspring/decimal"
-)
-
-// Service Trx 钱包信息
-type Service struct {
- zenrpc.Service
- Contract string
- Port string
-}
-
-// Getinfo 获取钱包信息
-func (as Service) Getinfo() util.Info {
- return getWalletInfoContract(as.Contract)
-}
-
-// GetNewAddress 获取新地址
-func (as Service) GetNewAddress() (string, error) {
- ac, err := creataddress()
- if err != nil {
- return "", err
- }
- return ac.Address, nil
-}
-
-// ValidateAddress 校验地址
-func (as Service) ValidateAddress(addr string) util.ValidateAddress {
- var resp util.ValidateAddress
- resp.IsValidate = validaddress(addr)
- return resp
-}
-
-// ListTransactions 获取指定地址最近的交易记录
-//zenrpc:count=300
-//zenrpc:skip=0
-//zenrpc:addr="*"
-func (as Service) ListTransactions(addr string, count, skip int) ([]util.Transactions, error) {
- return recentTransactions(as.Contract, addr, count, skip)
-}
-
-// SendToAddress 提币请求
-func (as Service) SendToAddress(addr string, amount json.Number) (string, error) {
- amountt, _ := decimal.NewFromString(string(amount))
- return sendOut(as.Contract, addr, amountt)
-}
-
-// GetRecords 归集交易记录 中转记录
-func (as Service) GetRecords(sTime, eTime int64) ([]util.SummaryData, error) {
- return collectTransactions(as.Contract, sTime, eTime)
-}
-
-//go:generate zenrpc
-
-// Serv 监听服务
-func Serv(ctx context.Context, rpcSev Service) *http.Server {
- server := &http.Server{}
- rpc := zenrpc.NewServer(zenrpc.Options{ExposeSMD: true})
- rpc.Register("", rpcSev)
- //rpc.Use(zenrpc.Logger(log.New(os.Stderr, "", log.LstdFlags)))
- httpw := http.NewServeMux()
- httpw.Handle("/", rpc)
- server.Handler = httpw
- server.Addr = ":" + rpcSev.Port
- go func() {
- err := server.ListenAndServe()
- if err != nil {
- fmt.Println(err)
- }
- }()
- return server
-}
-
-// InitAllContarctServer 初始化所有节点
-func InitAllContarctServer(ctx context.Context, exit chan<- struct{}) {
- var servers []*http.Server
- var service = Service{
- Contract: Trx,
- Port: port,
- }
- servers = append(servers, Serv(ctx, service))
- for _, v := range mapContract {
- service.Contract = v.Contract
- service.Port = v.Port
- servers = append(servers, Serv(ctx, service))
- }
- go func() {
- <-ctx.Done()
- for _, v := range servers {
- v.Close()
- }
- canceltask()
- wg.Wait()
- exit <- struct{}{}
- }()
-}
+package trx
+
+import (
+ "context"
+ "encoding/json"
+ "fmt"
+ "github.com/heybeachboy/trx/util"
+ "net/http"
+
+ "github.com/semrush/zenrpc/v2"
+ "github.com/shopspring/decimal"
+)
+
+// Service Trx 钱包信息
+type Service struct {
+ zenrpc.Service
+ Contract string
+ Port string
+}
+
+// Getinfo 获取钱包信息
+func (as Service) Getinfo() util.Info {
+ return getWalletInfoContract(as.Contract)
+}
+
+// GetNewAddress 获取新地址
+func (as Service) GetNewAddress() (string, error) {
+ ac, err := creataddress()
+ if err != nil {
+ return "", err
+ }
+ return ac.Address, nil
+}
+
+// ValidateAddress 校验地址
+func (as Service) ValidateAddress(addr string) util.ValidateAddress {
+ var resp util.ValidateAddress
+ resp.IsValidate = validaddress(addr)
+ return resp
+}
+
+// ListTransactions 获取指定地址最近的交易记录
+//
+//zenrpc:count=300
+//zenrpc:skip=0
+//zenrpc:addr="*"
+func (as Service) ListTransactions(addr string, count, skip int) ([]util.Transactions, error) {
+ return recentTransactions(as.Contract, addr, count, skip)
+}
+
+// SendToAddress 提币请求
+func (as Service) SendToAddress(addr string, amount json.Number) (string, error) {
+ amountt, _ := decimal.NewFromString(string(amount))
+ return sendOut(as.Contract, addr, amountt)
+}
+
+// GetRecords 归集交易记录 中转记录
+func (as Service) GetRecords(sTime, eTime int64) ([]util.SummaryData, error) {
+ return collectTransactions(as.Contract, sTime, eTime)
+}
+
+//go:generate zenrpc
+
+// Serv 监听服务
+func Serv(ctx context.Context, rpcSev Service) *http.Server {
+ server := &http.Server{}
+ rpc := zenrpc.NewServer(zenrpc.Options{ExposeSMD: true})
+ rpc.Register("", rpcSev)
+ //rpc.Use(zenrpc.Logger(log.New(os.Stderr, "", log.LstdFlags)))
+ httpw := http.NewServeMux()
+ httpw.Handle("/", rpc)
+ server.Handler = httpw
+ server.Addr = ":" + rpcSev.Port
+ go func() {
+ err := server.ListenAndServe()
+ if err != nil {
+ fmt.Println(err)
+ }
+ }()
+ return server
+}
+
+// InitAllContarctServer 初始化所有节点
+func InitAllContarctServer(ctx context.Context, exit chan<- struct{}) {
+ var servers []*http.Server
+ var service = Service{
+ Contract: Trx,
+ Port: port,
+ }
+ servers = append(servers, Serv(ctx, service))
+ for _, v := range mapContract {
+ service.Contract = v.Contract
+ service.Port = v.Port
+ servers = append(servers, Serv(ctx, service))
+ }
+ go func() {
+ <-ctx.Done()
+ for _, v := range servers {
+ v.Close()
+ }
+ canceltask()
+ wg.Wait()
+ exit <- struct{}{}
+ }()
+}
diff --git a/trx/task.go b/trx/task.go
index d0a68f0..c4122db 100644
--- a/trx/task.go
+++ b/trx/task.go
@@ -1,286 +1,286 @@
-package trx
-
-import (
- "sync"
- "time"
- "tron/log"
-
- "github.com/shopspring/decimal"
-)
-
-// 每次批量查询最多100个 100个会body很大 所以这里限制20个
-var count int64 = 20
-
-// RunTransaction .
-func RunTransaction() {
- tmpendheight := blockHeightTop
- dvalue := tmpendheight - targetHeight
- if dvalue < 1 {
- return
- }
- countnum := dvalue / count // 总共单位请求数量
- if dvalue%count > 0 {
- countnum++
- }
- daverage := countnum / goroutineNumScan // 循环次数
-
- remaning := countnum % goroutineNumScan // 最后一次的次数
-
- blockHeight := targetHeight
-
- var wg = &sync.WaitGroup{}
- var i int64 = 0
- for ; i < daverage; i++ {
- var j int64 = 0
- for ; j < goroutineNumScan; j++ {
- wg.Add(1)
- go func(start, end int64) {
- getBlockWithHeights(start, end)
- wg.Done()
- }(blockHeight, blockHeight+count)
- blockHeight += count
- }
- wg.Wait()
- if blockHeight > tmpendheight {
- targetHeight = tmpendheight
- } else {
- targetHeight = blockHeight
- }
- err := dbengine.InsertLastBlockHeight(targetHeight)
- log.Infof("insert height %d err %v", targetHeight, err)
- select {
- case <-ctx.Done():
- return
- default:
- }
- }
- if remaning > 0 {
- for i = 0; i < remaning; i++ {
- wg.Add(1)
- go func(start, end int64) {
- getBlockWithHeights(start, end)
- wg.Done()
- }(blockHeight, blockHeight+count)
- blockHeight += count
- }
- wg.Wait()
- targetHeight = tmpendheight
- err := dbengine.InsertLastBlockHeight(targetHeight)
- log.Infof("insert height %d err %v", targetHeight, err)
- }
-}
-
-// 成交归集检测
-func collectall(addr string) {
- // 成交归集检测
- _, err := loadAccount(addr)
-
- if err != nil {
- log.Errorf("loadAccount addr %s err: %s", addr, err.Error())
- return
- }
-
- // 获取波场余额
- amounttrx, err := getBalanceByAddress("", addr)
- if err != nil {
- log.Errorf("getBalance trx %s addr %s err: %s", addr, err.Error())
- return
- }
- // 检测满足归集的合约余额数量标记
- var coll = make(map[string]decimal.Decimal, 0)
- for _, v := range mapContract {
- amount, err := getBalanceByAddress(v.Contract, addr)
- if err != nil {
- log.Errorf("getBalance contract %s addr %s err: %s", v.Contract, addr, err.Error())
- continue
- }
- log.Infof("getBalance contract %s addr %s is %s", v.Contract, addr, amount.String())
- if amount.GreaterThanOrEqual(v.CollectionMinAmount) {
- coll[v.Contract] = amount
- }
- // 更新余额
- var amountdecimal = decimal.New(1, v.Decimal)
- amountac, _ := amount.Mul(amountdecimal).Float64()
- var tmp = &Balance{
- Address: addr,
- Contract: v.Contract,
- Amount: int64(amountac),
- }
- _, err = dbengine.InsertBalance(tmp)
- if err != nil {
- log.Errorf("UpdateBalance %v err: %s", *tmp, err)
- }
- }
- // 有归集的合约
- if len(coll) > 0 {
- // 合计每个合约预留trx数量
- feeAmount := decimal.NewFromInt32(int32(len(coll))).Mul(perFee)
-
- if amounttrx.LessThan(feeAmount) {
- transfee := feeAmount.Add(minFee).Sub(amounttrx)
- txid, err := sendFee(addr, transfee)
- if err != nil {
- log.Errorf("send fee %s addr %s err: %s", transfee.String(), addr, err.Error())
- } else {
- log.Infof("send fee %s addr %s txid: %s", transfee.String(), addr, txid)
- // 波场一般3秒一个块 12个确认的话 就是 36秒 等待36秒
- time.Sleep(36 * time.Second)
- // 这里不做进一步判断余额了
- }
- }
- for contract, v := range coll {
- txid, err := sendIn(contract, addr, v)
- if err != nil {
- // 有可能是成功了的
- log.Errorf("contract %s addr %s the collect txid: %s err: %s", contract, addr, txid, err.Error())
- } else {
- log.Infof("contract %s addr %s the collect txid: %s", contract, addr, txid)
- }
- time.Sleep(10 * time.Second)
- amount, err := getBalanceByAddress(contract, addr)
- if err != nil {
- log.Errorf("getBalance contract %s addr %s err: %s", contract, addr, err.Error())
- continue
- }
- log.Infof("getBalance contract %s addr %s is %s", contract, addr, amount.String())
- // 更新余额
- var amountdecimal = decimal.New(1, mapContract[contract].Decimal)
- amountac, _ := amount.Mul(amountdecimal).Float64()
- var tmp = &Balance{
- Address: addr,
- Contract: contract,
- Amount: int64(amountac),
- }
- _, err = dbengine.InsertBalance(tmp)
- if err != nil {
- log.Errorf("UpdateBalance %v err: %s", *tmp, err)
- }
- }
- }
-
- // 再次获取波场余额 是否归集
- amounttrx, err = getBalanceByAddress("", addr)
- if err != nil {
- log.Errorf("getBalance trx %s addr %s err: %s", addr, err.Error())
- return
- }
- // 满足最小归集量 满足预留最小数量
- if amounttrx.GreaterThan(minAmount) && amounttrx.GreaterThan(remainAmount) {
- v := amounttrx.Sub(remainAmount)
- txid, err := sendIn("", addr, v)
- if err != nil {
- // 有可能是成功了的
- log.Errorf("collect trx %s addr %s err: %s", addr, err.Error())
- } else {
- log.Infof("trx addr %s the collect txid: %s", addr, txid)
- }
- time.Sleep(10 * time.Second)
- amounttrx, err = getBalanceByAddress("", addr)
- if err != nil {
- log.Errorf("getBalance trx %s addr %s err: %s", addr, err.Error())
- return
- }
- }
- // 更新余额
- amountac, _ := amounttrx.Mul(decimal.New(1, 6)).Float64()
- var tmp = &Balance{
- Address: addr,
- Contract: "",
- Amount: int64(amountac),
- }
- _, err = dbengine.InsertBalance(tmp)
- if err != nil {
- log.Errorf("UpdateBalance %v err: %s", *tmp, err)
- }
-}
-
-// RunCollect 获取数据库中 大于指定余额钱包余额进行归集
-func RunCollect() {
- // 归集检测 并行100个任务
- var task = make(chan bool, 100)
- var wgcollect sync.WaitGroup // 保持等待所有任务结束
- defer wgcollect.Wait()
- count := 1000
- var minAmountv int64
-
- for _, v := range mapContract {
- var startid int64
- tmp, _ := v.CollectionMinAmount.Mul(decimal.New(1, v.Decimal)).Float64()
- minAmountv = int64(tmp)
- for {
- addr, err := dbengine.GetAccountWithContractBalance(v.Contract, minAmountv, startid, count)
- if err != nil {
- log.Errorf("GetAccountWithContractBalance err:%v", err)
- select {
- case <-ctx.Done():
- return
- default:
- }
- break
- }
- var lens = len(addr)
- log.Infof("collect Contract %s nums %d", v.Contract, lens)
- for i := 0; i < lens; i++ {
- startid = addr[i].ID
- wgcollect.Add(1)
- task <- true
- go func(k int) {
- collectall(addr[k].Address)
- wgcollect.Done()
- <-task
- }(i)
- select {
- case <-ctx.Done():
- return
- default:
- }
- }
- if lens < count {
- break
- }
- time.Sleep(time.Second)
- }
- time.Sleep(time.Second)
- }
-
- var id int64 = 0
- tmp, _ := minAmount.Mul(decimal.New(1, 6)).Float64()
- minAmountv = int64(tmp)
- for {
- addr, err := dbengine.GetAccountWithContractBalance("", minAmountv, id, count)
- if err != nil {
- log.Errorf("GetAccountWithContractBalance err:%v", err)
- select {
- case <-ctx.Done():
- return
- default:
- }
- break
- }
- var lens = len(addr)
- log.Infof("collect trx nums %d", lens)
- if lens < 1 {
- return
- }
-
- for i := 0; i < lens; i++ {
- id = addr[i].ID
- if addr[i].Address == mainAddr {
- continue
- }
- wgcollect.Add(1)
- task <- true
- go func(k int) {
- collectall(addr[k].Address)
- wgcollect.Done()
- <-task
- }(i)
- select {
- case <-ctx.Done():
- return
- default:
- }
- }
- time.Sleep(time.Second)
- }
-}
+package trx
+
+import (
+ "github.com/heybeachboy/trx/log"
+ "sync"
+ "time"
+
+ "github.com/shopspring/decimal"
+)
+
+// 每次批量查询最多100个 100个会body很大 所以这里限制20个
+var count int64 = 20
+
+// RunTransaction .
+func RunTransaction() {
+ tmpendheight := blockHeightTop
+ dvalue := tmpendheight - targetHeight
+ if dvalue < 1 {
+ return
+ }
+ countnum := dvalue / count // 总共单位请求数量
+ if dvalue%count > 0 {
+ countnum++
+ }
+ daverage := countnum / goroutineNumScan // 循环次数
+
+ remaning := countnum % goroutineNumScan // 最后一次的次数
+
+ blockHeight := targetHeight
+
+ var wg = &sync.WaitGroup{}
+ var i int64 = 0
+ for ; i < daverage; i++ {
+ var j int64 = 0
+ for ; j < goroutineNumScan; j++ {
+ wg.Add(1)
+ go func(start, end int64) {
+ getBlockWithHeights(start, end)
+ wg.Done()
+ }(blockHeight, blockHeight+count)
+ blockHeight += count
+ }
+ wg.Wait()
+ if blockHeight > tmpendheight {
+ targetHeight = tmpendheight
+ } else {
+ targetHeight = blockHeight
+ }
+ err := dbengine.InsertLastBlockHeight(targetHeight)
+ log.Infof("insert height %d err %v", targetHeight, err)
+ select {
+ case <-ctx.Done():
+ return
+ default:
+ }
+ }
+ if remaning > 0 {
+ for i = 0; i < remaning; i++ {
+ wg.Add(1)
+ go func(start, end int64) {
+ getBlockWithHeights(start, end)
+ wg.Done()
+ }(blockHeight, blockHeight+count)
+ blockHeight += count
+ }
+ wg.Wait()
+ targetHeight = tmpendheight
+ err := dbengine.InsertLastBlockHeight(targetHeight)
+ log.Infof("insert height %d err %v", targetHeight, err)
+ }
+}
+
+// 成交归集检测
+func collectall(addr string) {
+ // 成交归集检测
+ _, err := loadAccount(addr)
+
+ if err != nil {
+ log.Errorf("loadAccount addr %s err: %s", addr, err.Error())
+ return
+ }
+
+ // 获取波场余额
+ amounttrx, err := getBalanceByAddress("", addr)
+ if err != nil {
+ log.Errorf("getBalance trx %s addr %s err: %s", addr, err.Error())
+ return
+ }
+ // 检测满足归集的合约余额数量标记
+ var coll = make(map[string]decimal.Decimal, 0)
+ for _, v := range mapContract {
+ amount, err := getBalanceByAddress(v.Contract, addr)
+ if err != nil {
+ log.Errorf("getBalance contract %s addr %s err: %s", v.Contract, addr, err.Error())
+ continue
+ }
+ log.Infof("getBalance contract %s addr %s is %s", v.Contract, addr, amount.String())
+ if amount.GreaterThanOrEqual(v.CollectionMinAmount) {
+ coll[v.Contract] = amount
+ }
+ // 更新余额
+ var amountdecimal = decimal.New(1, v.Decimal)
+ amountac, _ := amount.Mul(amountdecimal).Float64()
+ var tmp = &Balance{
+ Address: addr,
+ Contract: v.Contract,
+ Amount: int64(amountac),
+ }
+ _, err = dbengine.InsertBalance(tmp)
+ if err != nil {
+ log.Errorf("UpdateBalance %v err: %s", *tmp, err)
+ }
+ }
+ // 有归集的合约
+ if len(coll) > 0 {
+ // 合计每个合约预留trx数量
+ feeAmount := decimal.NewFromInt32(int32(len(coll))).Mul(perFee)
+
+ if amounttrx.LessThan(feeAmount) {
+ transfee := feeAmount.Add(minFee).Sub(amounttrx)
+ txid, err := sendFee(addr, transfee)
+ if err != nil {
+ log.Errorf("send fee %s addr %s err: %s", transfee.String(), addr, err.Error())
+ } else {
+ log.Infof("send fee %s addr %s txid: %s", transfee.String(), addr, txid)
+ // 波场一般3秒一个块 12个确认的话 就是 36秒 等待36秒
+ time.Sleep(36 * time.Second)
+ // 这里不做进一步判断余额了
+ }
+ }
+ for contract, v := range coll {
+ txid, err := sendIn(contract, addr, v)
+ if err != nil {
+ // 有可能是成功了的
+ log.Errorf("contract %s addr %s the collect txid: %s err: %s", contract, addr, txid, err.Error())
+ } else {
+ log.Infof("contract %s addr %s the collect txid: %s", contract, addr, txid)
+ }
+ time.Sleep(10 * time.Second)
+ amount, err := getBalanceByAddress(contract, addr)
+ if err != nil {
+ log.Errorf("getBalance contract %s addr %s err: %s", contract, addr, err.Error())
+ continue
+ }
+ log.Infof("getBalance contract %s addr %s is %s", contract, addr, amount.String())
+ // 更新余额
+ var amountdecimal = decimal.New(1, mapContract[contract].Decimal)
+ amountac, _ := amount.Mul(amountdecimal).Float64()
+ var tmp = &Balance{
+ Address: addr,
+ Contract: contract,
+ Amount: int64(amountac),
+ }
+ _, err = dbengine.InsertBalance(tmp)
+ if err != nil {
+ log.Errorf("UpdateBalance %v err: %s", *tmp, err)
+ }
+ }
+ }
+
+ // 再次获取波场余额 是否归集
+ amounttrx, err = getBalanceByAddress("", addr)
+ if err != nil {
+ log.Errorf("getBalance trx %s addr %s err: %s", addr, err.Error())
+ return
+ }
+ // 满足最小归集量 满足预留最小数量
+ if amounttrx.GreaterThan(minAmount) && amounttrx.GreaterThan(remainAmount) {
+ v := amounttrx.Sub(remainAmount)
+ txid, err := sendIn("", addr, v)
+ if err != nil {
+ // 有可能是成功了的
+ log.Errorf("collect trx %s addr %s err: %s", addr, err.Error())
+ } else {
+ log.Infof("trx addr %s the collect txid: %s", addr, txid)
+ }
+ time.Sleep(10 * time.Second)
+ amounttrx, err = getBalanceByAddress("", addr)
+ if err != nil {
+ log.Errorf("getBalance trx %s addr %s err: %s", addr, err.Error())
+ return
+ }
+ }
+ // 更新余额
+ amountac, _ := amounttrx.Mul(decimal.New(1, 6)).Float64()
+ var tmp = &Balance{
+ Address: addr,
+ Contract: "",
+ Amount: int64(amountac),
+ }
+ _, err = dbengine.InsertBalance(tmp)
+ if err != nil {
+ log.Errorf("UpdateBalance %v err: %s", *tmp, err)
+ }
+}
+
+// RunCollect 获取数据库中 大于指定余额钱包余额进行归集
+func RunCollect() {
+ // 归集检测 并行100个任务
+ var task = make(chan bool, 100)
+ var wgcollect sync.WaitGroup // 保持等待所有任务结束
+ defer wgcollect.Wait()
+ count := 1000
+ var minAmountv int64
+
+ for _, v := range mapContract {
+ var startid int64
+ tmp, _ := v.CollectionMinAmount.Mul(decimal.New(1, v.Decimal)).Float64()
+ minAmountv = int64(tmp)
+ for {
+ addr, err := dbengine.GetAccountWithContractBalance(v.Contract, minAmountv, startid, count)
+ if err != nil {
+ log.Errorf("GetAccountWithContractBalance err:%v", err)
+ select {
+ case <-ctx.Done():
+ return
+ default:
+ }
+ break
+ }
+ var lens = len(addr)
+ log.Infof("collect Contract %s nums %d", v.Contract, lens)
+ for i := 0; i < lens; i++ {
+ startid = addr[i].ID
+ wgcollect.Add(1)
+ task <- true
+ go func(k int) {
+ collectall(addr[k].Address)
+ wgcollect.Done()
+ <-task
+ }(i)
+ select {
+ case <-ctx.Done():
+ return
+ default:
+ }
+ }
+ if lens < count {
+ break
+ }
+ time.Sleep(time.Second)
+ }
+ time.Sleep(time.Second)
+ }
+
+ var id int64 = 0
+ tmp, _ := minAmount.Mul(decimal.New(1, 6)).Float64()
+ minAmountv = int64(tmp)
+ for {
+ addr, err := dbengine.GetAccountWithContractBalance("", minAmountv, id, count)
+ if err != nil {
+ log.Errorf("GetAccountWithContractBalance err:%v", err)
+ select {
+ case <-ctx.Done():
+ return
+ default:
+ }
+ break
+ }
+ var lens = len(addr)
+ log.Infof("collect trx nums %d", lens)
+ if lens < 1 {
+ return
+ }
+
+ for i := 0; i < lens; i++ {
+ id = addr[i].ID
+ if addr[i].Address == mainAddr {
+ continue
+ }
+ wgcollect.Add(1)
+ task <- true
+ go func(k int) {
+ collectall(addr[k].Address)
+ wgcollect.Done()
+ <-task
+ }(i)
+ select {
+ case <-ctx.Done():
+ return
+ default:
+ }
+ }
+ time.Sleep(time.Second)
+ }
+}
diff --git a/trx/transcation.go b/trx/transcation.go
index 18f801b..5ea55e3 100644
--- a/trx/transcation.go
+++ b/trx/transcation.go
@@ -1,454 +1,454 @@
-package trx
-
-import (
- "crypto/ecdsa"
- "encoding/json"
- "fmt"
- "math/big"
- "time"
- "tron/api"
- "tron/core"
- "tron/hexutil"
- "tron/log"
- "tron/service"
-
- wallet "tron/util"
-
- "github.com/ethereum/go-ethereum/common"
- "github.com/shopspring/decimal"
- "github.com/smirkcat/hdwallet"
- "google.golang.org/protobuf/proto"
-)
-
-// 每次最多100 个
-func getBlockWithHeights(start, end int64) {
- if end-start < 1 {
- return
- }
- var node *service.GrpcClient
-againblock:
- if node != nil {
- node.Conn.Close()
- }
- select {
- case <-ctx.Done():
- return
- default:
- }
- node = getRandOneNode()
- block, err := node.GetBlockByLimitNext(start, end)
- if err != nil {
- // rpc error: code = DeadlineExceeded desc = context deadline exceeded will get again
- log.Warnf("node get bolck start %d end %d GetBlockByLimitNext err: %v will get again", start, end, err)
- time.Sleep(time.Second * 5)
- goto againblock
- }
- log.Infof("node get bolck start %d end %d length %d", start, end, len(block.Block))
- if len(block.Block) < 1 {
- log.Warnf("get bolck zero lenghth of block start %d end %d, will get again", start, end)
- time.Sleep(time.Second * 5)
- goto againblock
- }
- processBlocks(block)
- node.Conn.Close()
-}
-
-func getBlockWithHeight(num int64) error {
- node := getRandOneNode()
- defer node.Conn.Close()
- block, err := node.GetBlockByNum(num)
- if err != nil {
- return err
- }
- processBlock(block)
- return nil
-}
-
-func processBlocks(blocks *api.BlockListExtention) {
- for _, v := range blocks.Block {
- processBlock(v)
- }
-}
-
-func getTransactionInfo(node *service.GrpcClient, txid string) *core.TransactionInfo {
-againtransinfo:
- select {
- case <-ctx.Done():
- return nil
- default:
- }
- transinfo, err := node.GetTransactionInfoById(txid)
- if err != nil {
- // rpc error: code = DeadlineExceeded desc = context deadline exceeded will get again
- log.Warnf("node get txid %s GetTransactionInfoById err: %v will get again", txid, err)
- time.Sleep(time.Second * 5)
- goto againtransinfo
- }
- return transinfo
-}
-
-// 通过translog判断合约转账 如果有转账有扣除,则需调用此方法更精确
-var transferid = "ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
-
-func processBlock(block *api.BlockExtention) {
- height := block.GetBlockHeader().GetRawData().GetNumber()
- node := getRandOneNode()
- defer node.Conn.Close()
- for _, v := range block.Transactions {
- // transaction.ret.contractRe
- txid := hexutil.Encode(v.Txid)
- // https://tronscan.org/#/transaction/fede1aa9e5c5d7bd179fd62e23bdd11e3c1edd0ca51e41070e34a026d6a42569
- if v.Result == nil || !v.Result.Result {
- continue
- }
- rets := v.Transaction.Ret
- if len(rets) < 1 || rets[0].ContractRet != core.Transaction_Result_SUCCESS {
- continue
- }
-
- log.Debugf("process block height %d txid %s", height, txid)
- var transinfo *core.TransactionInfo
- var fee int64
- // 这里只能有一个
- for _, v1 := range v.Transaction.RawData.Contract {
- if v1.Type == core.Transaction_Contract_TransferContract { //转账合约
- // trx 转账
- unObj := &core.TransferContract{}
- err := proto.Unmarshal(v1.Parameter.GetValue(), unObj)
- if err != nil {
- log.Errorf("parse Contract %v err: %v", v1, err)
- continue
- }
- form := hdwallet.EncodeCheck(unObj.GetOwnerAddress())
- to := hdwallet.EncodeCheck(unObj.GetToAddress())
- processTransaction(node, Trx, txid, form, to, height, unObj.GetAmount(), fee)
- } else if v1.Type == core.Transaction_Contract_TriggerSmartContract { //调用智能合约
- // trc20 转账
- unObj := &core.TriggerSmartContract{}
- err := proto.Unmarshal(v1.Parameter.GetValue(), unObj)
- if err != nil {
- log.Errorf("parse Contract %v err: %v", v1, err)
- continue
- }
-
- contract := hdwallet.EncodeCheck(unObj.GetContractAddress())
- if !IsContract(contract) {
- continue
- }
- from := hdwallet.EncodeCheck(unObj.GetOwnerAddress())
- data := unObj.GetData()
- // unObj.Data https://goethereumbook.org/en/transfer-tokens/ 参考eth 操作
- // 只处理 transfer函数产生的交易
- _, _, flag := processTransferData(data, from)
- if flag { // 只有调用了 transfer(address,uint256) 才处理转账
- // 手续费处理 eth 类似 recipt
- if transinfo == nil {
- transinfo = getTransactionInfo(node, txid)
- }
- if transinfo == nil {
- continue
- }
- fee = transinfo.GetFee()
- // 处理 evenlog 合约转账,如有些合约发起转账并不是全部到账
- // https://tronscan.org/#/address/TWsZk6fs7UisoJAFXiMDXk9aF4PPRzVywZ/transfers
- // https://tronscan.org/#/transaction/0384391ab3ecdf70ffa6e20244718a06b998b8af8a226cda46871dec60b5f14d
- for _, evenlog := range transinfo.Log {
- contract, from, to, amount, flag := processEvenlogData(evenlog)
- if flag {
- processTransaction(node, contract, txid, from, to, height, amount, fee)
- }
- }
- }
- } else if v1.Type == core.Transaction_Contract_TransferAssetContract { //通证转账合约
- // trc10 转账
- unObj := &core.TransferAssetContract{}
- err := proto.Unmarshal(v1.Parameter.GetValue(), unObj)
- if err != nil {
- log.Errorf("parse Contract %v err: %v", v1, err)
- continue
- }
- contract := hdwallet.EncodeCheck(unObj.GetAssetName())
- form := hdwallet.EncodeCheck(unObj.GetOwnerAddress())
- to := hdwallet.EncodeCheck(unObj.GetToAddress())
- processTransaction(node, contract, txid, form, to, height, unObj.GetAmount(), fee)
- }
- }
- }
-}
-
-// 处理合约事件参数
-func processEvenlogData(evenlog *core.TransactionInfo_Log) (contract, from, to string, amount int64, flag bool) {
- tmpaddr := evenlog.GetAddress()
- tmpaddr = append([]byte{0x41}, tmpaddr...)
- contract = hdwallet.EncodeCheck(tmpaddr[:])
- if !IsContract(contract) {
- return
- }
-
- amount = new(big.Int).SetBytes(common.TrimLeftZeroes(evenlog.Data)).Int64()
-
- if len(evenlog.Topics) != 3 {
- return
- }
- if transferid != hexutil.Encode(evenlog.Topics[0]) {
- return
- }
- if len(evenlog.Topics[1]) != 32 || len(evenlog.Topics[2]) != 32 {
- return
- }
- evenlog.Topics[1][11] = 0x41
- evenlog.Topics[2][11] = 0x41
- from = hdwallet.EncodeCheck(evenlog.Topics[1][11:])
- to = hdwallet.EncodeCheck(evenlog.Topics[2][11:])
- flag = true
- return
-}
-
-// 这个结构目前没有用到 只是记录Trc20合约调用对应转换结果
-var mapFunctionTcc20 = map[string]string{
- "a9059cbb": "transfer(address,uint256)",
- "70a08231": "balanceOf(address)",
-}
-
-// a9059cbb 4 8
-// 00000000000000000000004173d5888eedd05efeda5bca710982d9c13b975f98 32 64
-// 0000000000000000000000000000000000000000000000000000000000989680 32 64
-
-// 处理合约参数
-func processTransferData(trc20 []byte, from string) (to string, amount int64, flag bool) {
- if len(trc20) >= 68 {
- if hexutil.Encode(trc20[:4]) != "a9059cbb" {
- return
- }
- // 多1位41
- trc20[15] = 65 // 0x41
- to = hdwallet.EncodeCheck(trc20[15:36])
- amount = new(big.Int).SetBytes(common.TrimLeftZeroes(trc20[36:68])).Int64()
- // 不在地址范围内 不处理
- if to == mainAddr || from == mainAddr {
- flag = true
- return
- }
- ac, _ := SearchAccount(to)
- if ac != nil {
- flag = true
- }
- // 归集
- ac, _ = SearchAccount(from)
- if ac != nil {
- flag = true
- }
- }
- return
-}
-
-// 处理合约转账参数
-func processTransferParameter(to string, amount int64) (data []byte) {
- methodID, _ := hexutil.Decode("a9059cbb")
- addr, _ := hdwallet.DecodeCheck(to)
- paddedAddress := common.LeftPadBytes(addr[1:], 32)
- amountBig := new(big.Int).SetInt64(amount)
- paddedAmount := common.LeftPadBytes(amountBig.Bytes(), 32)
- data = append(data, methodID...)
- data = append(data, paddedAddress...)
- data = append(data, paddedAmount...)
- return
-}
-
-// 处理合约获取余额
-func processBalanceOfData(trc20 []byte) (amount int64) {
- if len(trc20) >= 32 {
- amount = new(big.Int).SetBytes(common.TrimLeftZeroes(trc20[0:32])).Int64()
- }
- return
-}
-
-// 处理合约获取余额参数
-func processBalanceOfParameter(addr string) (data []byte) {
- methodID, _ := hexutil.Decode("70a08231")
- add, _ := hdwallet.DecodeCheck(addr)
- paddedAddress := common.LeftPadBytes(add[1:], 32)
- data = append(data, methodID...)
- data = append(data, paddedAddress...)
- return
-}
-
-func processTransaction(node *service.GrpcClient, contract, txid, from, to string, blockheight, amount, fee int64) {
-
- // 合约是否存在
- if !IsContract(contract) {
- return
- }
- // fmt.Printf("contract %s txid %s from %s to %s, blockheight %d amount %d \n",
- // contract, txid, from, to, blockheight, amount)
- var types string
- var pub string
- if from == mainAddr { // 提币 or 中转
- ac, err := SearchAccount(to)
- if err != nil {
- log.Error(err)
- }
- if ac != nil {
- pub = ac.PublicKey
- types = Collect // 手续费划转
- } else {
- types = Send
- }
- } else if to == mainAddr { // 归集记录
- ac, err := SearchAccount(from)
- if err != nil {
- log.Error(err)
- }
- if ac != nil {
- types = Collect
- } else {
- types = ReceiveOther
- }
- } else {
- acf, err := SearchAccount(from)
- if err != nil {
- log.Error(err)
- }
- act, err := SearchAccount(to)
- if err != nil {
- log.Error(err)
- }
- if act != nil { // 收币地址
- pub = act.PublicKey
- if acf != nil {
- types = CollectOwn // 站内转账 暂时不可能触发
- } else {
- types = Receive
- go collectall(to) // 归集检测
- }
- } else {
- if acf != nil {
- types = CollectSend // 转账到外面地址 异常
- } else {
- return // 不处理 都不是平台的地址
- }
- }
- }
-
- if fee == 0 {
- transinfo, err := node.GetTransactionInfoById(txid)
- if err != nil {
- log.Error(err)
- } else {
- fee = transinfo.GetFee()
- }
- }
-
- _, decimalnum := chargeContract(contract)
- var trans = &Transactions{
- TxID: txid,
- Contract: contract,
- Type: types,
- BlockHeight: blockheight,
- Amount: decimal.New(amount, -decimalnum).String(),
- Fee: decimal.New(fee, -trxdecimal).String(),
- Timestamp: time.Now().Unix(),
- PublicKey: pub,
- Address: to,
- FromAddress: from,
- }
-
- _, err := dbengine.InsertTransactions(trans)
- if err != nil {
- log.Infof("InsertTransactions %v err %v ", trans, err)
- }
-}
-
-// 转账合约燃烧 trx数量 单位 sun 默认5trx 转账一笔大概消耗能量 0.26trx
-var feelimit int64 = 5000000
-
-// 转币
-func send(key *ecdsa.PrivateKey, contract, to string, amount decimal.Decimal) (string, error) {
- node := getRandOneNode()
- defer node.Conn.Close()
- typs, decimalnum := chargeContract(contract)
- var amountdecimal = decimal.New(1, decimalnum)
- amountac, _ := amount.Mul(amountdecimal).Float64()
- switch typs {
- case Trc10:
- return node.TransferAsset(key, contract, to, int64(amountac))
- case Trx:
- return node.Transfer(key, to, int64(amountac))
- case Trc20:
- data := processTransferParameter(to, int64(amountac))
- return node.TransferContract(key, contract, data, feelimit)
- }
- return "", fmt.Errorf("the type %s not support now", typs)
-}
-
-// 往外转 提币
-func sendOut(contract, to string, amount decimal.Decimal) (string, error) {
- return send(mainAccout, contract, to, amount)
-}
-
-// 往地址转手续费
-func sendFee(to string, amount decimal.Decimal) (string, error) {
- return send(mainAccout, Trx, to, amount)
-}
-
-// 归集
-func sendIn(contract, from string, amount decimal.Decimal) (string, error) {
- var accout *ecdsa.PrivateKey
- accout, err := loadAccount(from)
- if err != nil {
- return "", err
- }
- return send(accout, contract, mainAddr, amount)
-}
-
-// 交易记录
-func recentTransactions(contract, addr string, count, skip int) ([]wallet.Transactions, error) {
- re, err := dbengine.GetTransactions(contract, addr, count, skip)
- lens := len(re)
- ral := make([]wallet.Transactions, lens)
- if err != nil {
- return ral, err
- }
- var account = "go-tron-" + contract + "-walletrpc"
- for i := 0; i < lens; i++ {
- ral[i].Address = re[i].Address
- ral[i].FromAddress = re[i].FromAddress
- ral[i].PublicKey = re[i].PublicKey
- ral[i].Fee = json.Number(re[i].Fee)
- ral[i].Amount = json.Number(re[i].Amount)
- ral[i].Category = re[i].Type
- ral[i].Confirmations = blockHeightTop - re[i].BlockHeight + 1
- ral[i].Time = re[i].Timestamp
- ral[i].TimeReceived = re[i].Timestamp
- ral[i].TxID = re[i].TxID
- ral[i].BlockIndex = re[i].BlockHeight
- ral[i].Account = account
- }
- return ral, nil
-}
-
-// 归集记录
-func collectTransactions(contract string, sTime, eTime int64) ([]wallet.SummaryData, error) {
- re, err := dbengine.GetCollestTransactions(sTime, eTime, contract)
- lens := len(re)
- ral := make([]wallet.SummaryData, lens)
- if err != nil {
- return ral, err
- }
- var account = "go-tron-" + contract + "-walletrpc"
- for i := 0; i < lens; i++ {
- ral[i].Address = re[i].Address
- ral[i].PublicKey = re[i].PublicKey
- ral[i].FromAddress = re[i].FromAddress
- ral[i].Fee = re[i].Fee
- ral[i].Amount = re[i].Amount
- ral[i].Category = re[i].Type
- ral[i].Time = re[i].Timestamp
- ral[i].TimeReceived = re[i].Timestamp
- ral[i].Blocktime = re[i].Timestamp
- ral[i].TxID = re[i].TxID
- ral[i].BlockIndex = re[i].BlockHeight
- ral[i].Account = account
- }
- return ral, nil
-}
+package trx
+
+import (
+ "crypto/ecdsa"
+ "encoding/json"
+ "fmt"
+ "github.com/heybeachboy/trx/api"
+ "github.com/heybeachboy/trx/core"
+ "github.com/heybeachboy/trx/hexutil"
+ "github.com/heybeachboy/trx/log"
+ "github.com/heybeachboy/trx/service"
+ "math/big"
+ "time"
+
+ wallet "github.com/heybeachboy/trx/util"
+
+ "github.com/ethereum/go-ethereum/common"
+ "github.com/shopspring/decimal"
+ "github.com/smirkcat/hdwallet"
+ "google.golang.org/protobuf/proto"
+)
+
+// 每次最多100 个
+func getBlockWithHeights(start, end int64) {
+ if end-start < 1 {
+ return
+ }
+ var node *service.GrpcClient
+againblock:
+ if node != nil {
+ node.Conn.Close()
+ }
+ select {
+ case <-ctx.Done():
+ return
+ default:
+ }
+ node = getRandOneNode()
+ block, err := node.GetBlockByLimitNext(start, end)
+ if err != nil {
+ // rpc error: code = DeadlineExceeded desc = context deadline exceeded will get again
+ log.Warnf("node get bolck start %d end %d GetBlockByLimitNext err: %v will get again", start, end, err)
+ time.Sleep(time.Second * 5)
+ goto againblock
+ }
+ log.Infof("node get bolck start %d end %d length %d", start, end, len(block.Block))
+ if len(block.Block) < 1 {
+ log.Warnf("get bolck zero lenghth of block start %d end %d, will get again", start, end)
+ time.Sleep(time.Second * 5)
+ goto againblock
+ }
+ processBlocks(block)
+ node.Conn.Close()
+}
+
+func getBlockWithHeight(num int64) error {
+ node := getRandOneNode()
+ defer node.Conn.Close()
+ block, err := node.GetBlockByNum(num)
+ if err != nil {
+ return err
+ }
+ processBlock(block)
+ return nil
+}
+
+func processBlocks(blocks *api.BlockListExtention) {
+ for _, v := range blocks.Block {
+ processBlock(v)
+ }
+}
+
+func getTransactionInfo(node *service.GrpcClient, txid string) *core.TransactionInfo {
+againtransinfo:
+ select {
+ case <-ctx.Done():
+ return nil
+ default:
+ }
+ transinfo, err := node.GetTransactionInfoById(txid)
+ if err != nil {
+ // rpc error: code = DeadlineExceeded desc = context deadline exceeded will get again
+ log.Warnf("node get txid %s GetTransactionInfoById err: %v will get again", txid, err)
+ time.Sleep(time.Second * 5)
+ goto againtransinfo
+ }
+ return transinfo
+}
+
+// 通过translog判断合约转账 如果有转账有扣除,则需调用此方法更精确
+var transferid = "ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
+
+func processBlock(block *api.BlockExtention) {
+ height := block.GetBlockHeader().GetRawData().GetNumber()
+ node := getRandOneNode()
+ defer node.Conn.Close()
+ for _, v := range block.Transactions {
+ // transaction.ret.contractRe
+ txid := hexutil.Encode(v.Txid)
+ // https://tronscan.org/#/transaction/fede1aa9e5c5d7bd179fd62e23bdd11e3c1edd0ca51e41070e34a026d6a42569
+ if v.Result == nil || !v.Result.Result {
+ continue
+ }
+ rets := v.Transaction.Ret
+ if len(rets) < 1 || rets[0].ContractRet != core.Transaction_Result_SUCCESS {
+ continue
+ }
+
+ log.Debugf("process block height %d txid %s", height, txid)
+ var transinfo *core.TransactionInfo
+ var fee int64
+ // 这里只能有一个
+ for _, v1 := range v.Transaction.RawData.Contract {
+ if v1.Type == core.Transaction_Contract_TransferContract { //转账合约
+ // trx 转账
+ unObj := &core.TransferContract{}
+ err := proto.Unmarshal(v1.Parameter.GetValue(), unObj)
+ if err != nil {
+ log.Errorf("parse Contract %v err: %v", v1, err)
+ continue
+ }
+ form := hdwallet.EncodeCheck(unObj.GetOwnerAddress())
+ to := hdwallet.EncodeCheck(unObj.GetToAddress())
+ processTransaction(node, Trx, txid, form, to, height, unObj.GetAmount(), fee)
+ } else if v1.Type == core.Transaction_Contract_TriggerSmartContract { //调用智能合约
+ // trc20 转账
+ unObj := &core.TriggerSmartContract{}
+ err := proto.Unmarshal(v1.Parameter.GetValue(), unObj)
+ if err != nil {
+ log.Errorf("parse Contract %v err: %v", v1, err)
+ continue
+ }
+
+ contract := hdwallet.EncodeCheck(unObj.GetContractAddress())
+ if !IsContract(contract) {
+ continue
+ }
+ from := hdwallet.EncodeCheck(unObj.GetOwnerAddress())
+ data := unObj.GetData()
+ // unObj.Data https://goethereumbook.org/en/transfer-tokens/ 参考eth 操作
+ // 只处理 transfer函数产生的交易
+ _, _, flag := processTransferData(data, from)
+ if flag { // 只有调用了 transfer(address,uint256) 才处理转账
+ // 手续费处理 eth 类似 recipt
+ if transinfo == nil {
+ transinfo = getTransactionInfo(node, txid)
+ }
+ if transinfo == nil {
+ continue
+ }
+ fee = transinfo.GetFee()
+ // 处理 evenlog 合约转账,如有些合约发起转账并不是全部到账
+ // https://tronscan.org/#/address/TWsZk6fs7UisoJAFXiMDXk9aF4PPRzVywZ/transfers
+ // https://tronscan.org/#/transaction/0384391ab3ecdf70ffa6e20244718a06b998b8af8a226cda46871dec60b5f14d
+ for _, evenlog := range transinfo.Log {
+ contract, from, to, amount, flag := processEvenlogData(evenlog)
+ if flag {
+ processTransaction(node, contract, txid, from, to, height, amount, fee)
+ }
+ }
+ }
+ } else if v1.Type == core.Transaction_Contract_TransferAssetContract { //通证转账合约
+ // trc10 转账
+ unObj := &core.TransferAssetContract{}
+ err := proto.Unmarshal(v1.Parameter.GetValue(), unObj)
+ if err != nil {
+ log.Errorf("parse Contract %v err: %v", v1, err)
+ continue
+ }
+ contract := hdwallet.EncodeCheck(unObj.GetAssetName())
+ form := hdwallet.EncodeCheck(unObj.GetOwnerAddress())
+ to := hdwallet.EncodeCheck(unObj.GetToAddress())
+ processTransaction(node, contract, txid, form, to, height, unObj.GetAmount(), fee)
+ }
+ }
+ }
+}
+
+// 处理合约事件参数
+func processEvenlogData(evenlog *core.TransactionInfo_Log) (contract, from, to string, amount int64, flag bool) {
+ tmpaddr := evenlog.GetAddress()
+ tmpaddr = append([]byte{0x41}, tmpaddr...)
+ contract = hdwallet.EncodeCheck(tmpaddr[:])
+ if !IsContract(contract) {
+ return
+ }
+
+ amount = new(big.Int).SetBytes(common.TrimLeftZeroes(evenlog.Data)).Int64()
+
+ if len(evenlog.Topics) != 3 {
+ return
+ }
+ if transferid != hexutil.Encode(evenlog.Topics[0]) {
+ return
+ }
+ if len(evenlog.Topics[1]) != 32 || len(evenlog.Topics[2]) != 32 {
+ return
+ }
+ evenlog.Topics[1][11] = 0x41
+ evenlog.Topics[2][11] = 0x41
+ from = hdwallet.EncodeCheck(evenlog.Topics[1][11:])
+ to = hdwallet.EncodeCheck(evenlog.Topics[2][11:])
+ flag = true
+ return
+}
+
+// 这个结构目前没有用到 只是记录Trc20合约调用对应转换结果
+var mapFunctionTcc20 = map[string]string{
+ "a9059cbb": "transfer(address,uint256)",
+ "70a08231": "balanceOf(address)",
+}
+
+// a9059cbb 4 8
+// 00000000000000000000004173d5888eedd05efeda5bca710982d9c13b975f98 32 64
+// 0000000000000000000000000000000000000000000000000000000000989680 32 64
+
+// 处理合约参数
+func processTransferData(trc20 []byte, from string) (to string, amount int64, flag bool) {
+ if len(trc20) >= 68 {
+ if hexutil.Encode(trc20[:4]) != "a9059cbb" {
+ return
+ }
+ // 多1位41
+ trc20[15] = 65 // 0x41
+ to = hdwallet.EncodeCheck(trc20[15:36])
+ amount = new(big.Int).SetBytes(common.TrimLeftZeroes(trc20[36:68])).Int64()
+ // 不在地址范围内 不处理
+ if to == mainAddr || from == mainAddr {
+ flag = true
+ return
+ }
+ ac, _ := SearchAccount(to)
+ if ac != nil {
+ flag = true
+ }
+ // 归集
+ ac, _ = SearchAccount(from)
+ if ac != nil {
+ flag = true
+ }
+ }
+ return
+}
+
+// 处理合约转账参数
+func processTransferParameter(to string, amount int64) (data []byte) {
+ methodID, _ := hexutil.Decode("a9059cbb")
+ addr, _ := hdwallet.DecodeCheck(to)
+ paddedAddress := common.LeftPadBytes(addr[1:], 32)
+ amountBig := new(big.Int).SetInt64(amount)
+ paddedAmount := common.LeftPadBytes(amountBig.Bytes(), 32)
+ data = append(data, methodID...)
+ data = append(data, paddedAddress...)
+ data = append(data, paddedAmount...)
+ return
+}
+
+// 处理合约获取余额
+func processBalanceOfData(trc20 []byte) (amount int64) {
+ if len(trc20) >= 32 {
+ amount = new(big.Int).SetBytes(common.TrimLeftZeroes(trc20[0:32])).Int64()
+ }
+ return
+}
+
+// 处理合约获取余额参数
+func processBalanceOfParameter(addr string) (data []byte) {
+ methodID, _ := hexutil.Decode("70a08231")
+ add, _ := hdwallet.DecodeCheck(addr)
+ paddedAddress := common.LeftPadBytes(add[1:], 32)
+ data = append(data, methodID...)
+ data = append(data, paddedAddress...)
+ return
+}
+
+func processTransaction(node *service.GrpcClient, contract, txid, from, to string, blockheight, amount, fee int64) {
+
+ // 合约是否存在
+ if !IsContract(contract) {
+ return
+ }
+ // fmt.Printf("contract %s txid %s from %s to %s, blockheight %d amount %d \n",
+ // contract, txid, from, to, blockheight, amount)
+ var types string
+ var pub string
+ if from == mainAddr { // 提币 or 中转
+ ac, err := SearchAccount(to)
+ if err != nil {
+ log.Error(err)
+ }
+ if ac != nil {
+ pub = ac.PublicKey
+ types = Collect // 手续费划转
+ } else {
+ types = Send
+ }
+ } else if to == mainAddr { // 归集记录
+ ac, err := SearchAccount(from)
+ if err != nil {
+ log.Error(err)
+ }
+ if ac != nil {
+ types = Collect
+ } else {
+ types = ReceiveOther
+ }
+ } else {
+ acf, err := SearchAccount(from)
+ if err != nil {
+ log.Error(err)
+ }
+ act, err := SearchAccount(to)
+ if err != nil {
+ log.Error(err)
+ }
+ if act != nil { // 收币地址
+ pub = act.PublicKey
+ if acf != nil {
+ types = CollectOwn // 站内转账 暂时不可能触发
+ } else {
+ types = Receive
+ go collectall(to) // 归集检测
+ }
+ } else {
+ if acf != nil {
+ types = CollectSend // 转账到外面地址 异常
+ } else {
+ return // 不处理 都不是平台的地址
+ }
+ }
+ }
+
+ if fee == 0 {
+ transinfo, err := node.GetTransactionInfoById(txid)
+ if err != nil {
+ log.Error(err)
+ } else {
+ fee = transinfo.GetFee()
+ }
+ }
+
+ _, decimalnum := chargeContract(contract)
+ var trans = &Transactions{
+ TxID: txid,
+ Contract: contract,
+ Type: types,
+ BlockHeight: blockheight,
+ Amount: decimal.New(amount, -decimalnum).String(),
+ Fee: decimal.New(fee, -trxdecimal).String(),
+ Timestamp: time.Now().Unix(),
+ PublicKey: pub,
+ Address: to,
+ FromAddress: from,
+ }
+
+ _, err := dbengine.InsertTransactions(trans)
+ if err != nil {
+ log.Infof("InsertTransactions %v err %v ", trans, err)
+ }
+}
+
+// 转账合约燃烧 trx数量 单位 sun 默认5trx 转账一笔大概消耗能量 0.26trx
+var feelimit int64 = 5000000
+
+// 转币
+func send(key *ecdsa.PrivateKey, contract, to string, amount decimal.Decimal) (string, error) {
+ node := getRandOneNode()
+ defer node.Conn.Close()
+ typs, decimalnum := chargeContract(contract)
+ var amountdecimal = decimal.New(1, decimalnum)
+ amountac, _ := amount.Mul(amountdecimal).Float64()
+ switch typs {
+ case Trc10:
+ return node.TransferAsset(key, contract, to, int64(amountac))
+ case Trx:
+ return node.Transfer(key, to, int64(amountac))
+ case Trc20:
+ data := processTransferParameter(to, int64(amountac))
+ return node.TransferContract(key, contract, data, feelimit)
+ }
+ return "", fmt.Errorf("the type %s not support now", typs)
+}
+
+// 往外转 提币
+func sendOut(contract, to string, amount decimal.Decimal) (string, error) {
+ return send(mainAccout, contract, to, amount)
+}
+
+// 往地址转手续费
+func sendFee(to string, amount decimal.Decimal) (string, error) {
+ return send(mainAccout, Trx, to, amount)
+}
+
+// 归集
+func sendIn(contract, from string, amount decimal.Decimal) (string, error) {
+ var accout *ecdsa.PrivateKey
+ accout, err := loadAccount(from)
+ if err != nil {
+ return "", err
+ }
+ return send(accout, contract, mainAddr, amount)
+}
+
+// 交易记录
+func recentTransactions(contract, addr string, count, skip int) ([]wallet.Transactions, error) {
+ re, err := dbengine.GetTransactions(contract, addr, count, skip)
+ lens := len(re)
+ ral := make([]wallet.Transactions, lens)
+ if err != nil {
+ return ral, err
+ }
+ var account = "go-tron-" + contract + "-walletrpc"
+ for i := 0; i < lens; i++ {
+ ral[i].Address = re[i].Address
+ ral[i].FromAddress = re[i].FromAddress
+ ral[i].PublicKey = re[i].PublicKey
+ ral[i].Fee = json.Number(re[i].Fee)
+ ral[i].Amount = json.Number(re[i].Amount)
+ ral[i].Category = re[i].Type
+ ral[i].Confirmations = blockHeightTop - re[i].BlockHeight + 1
+ ral[i].Time = re[i].Timestamp
+ ral[i].TimeReceived = re[i].Timestamp
+ ral[i].TxID = re[i].TxID
+ ral[i].BlockIndex = re[i].BlockHeight
+ ral[i].Account = account
+ }
+ return ral, nil
+}
+
+// 归集记录
+func collectTransactions(contract string, sTime, eTime int64) ([]wallet.SummaryData, error) {
+ re, err := dbengine.GetCollestTransactions(sTime, eTime, contract)
+ lens := len(re)
+ ral := make([]wallet.SummaryData, lens)
+ if err != nil {
+ return ral, err
+ }
+ var account = "go-tron-" + contract + "-walletrpc"
+ for i := 0; i < lens; i++ {
+ ral[i].Address = re[i].Address
+ ral[i].PublicKey = re[i].PublicKey
+ ral[i].FromAddress = re[i].FromAddress
+ ral[i].Fee = re[i].Fee
+ ral[i].Amount = re[i].Amount
+ ral[i].Category = re[i].Type
+ ral[i].Time = re[i].Timestamp
+ ral[i].TimeReceived = re[i].Timestamp
+ ral[i].Blocktime = re[i].Timestamp
+ ral[i].TxID = re[i].TxID
+ ral[i].BlockIndex = re[i].BlockHeight
+ ral[i].Account = account
+ }
+ return ral, nil
+}
diff --git a/util/transaction.go b/util/transaction.go
index 56b7a60..eeade04 100644
--- a/util/transaction.go
+++ b/util/transaction.go
@@ -3,8 +3,8 @@ package util
import (
"crypto/ecdsa"
"crypto/sha256"
+ "github.com/heybeachboy/trx/core"
"time"
- "tron/core"
"github.com/ethereum/go-ethereum/crypto"