summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Winder <wwinder.unh@gmail.com>2021-12-20 08:35:53 -0500
committerGitHub <noreply@github.com>2021-12-20 08:35:53 -0500
commit22a5ebbbe9707f9cce706bcff11347bcf7217e06 (patch)
tree49dac84b7626c9b020bba2eaae9e8a63e0b61bde
parent9cdcb39b87cebdb44452a3ca21914472783370bd (diff)
Add convertAddress tool. (#3304)
## Summary New tool: convertAddress I share this tool with someone every few months, putting it in the repo along with some documentation should make it easier to share and encourage people to share it amongst themselves if it's useful. Merge `debug` into `tools` to make it easier to organize these miscellaneous tools.
-rw-r--r--README.md5
-rw-r--r--tools/README.md20
-rw-r--r--tools/debug/carpenter/main.go (renamed from debug/carpenter/main.go)0
-rw-r--r--tools/debug/coroner/main.go (renamed from debug/coroner/main.go)0
-rw-r--r--tools/debug/doberman/logo.go (renamed from debug/doberman/logo.go)0
-rw-r--r--tools/debug/doberman/main.go (renamed from debug/doberman/main.go)0
-rw-r--r--tools/debug/genconsensusconfig/main.go (renamed from debug/genconsensusconfig/main.go)0
-rwxr-xr-xtools/debug/jslog (renamed from debug/jslog)0
-rw-r--r--tools/debug/logfilter/example1.in (renamed from debug/logfilter/example1.in)0
-rw-r--r--tools/debug/logfilter/example1.out.expected (renamed from debug/logfilter/example1.out.expected)0
-rw-r--r--tools/debug/logfilter/example2.in (renamed from debug/logfilter/example2.in)0
-rw-r--r--tools/debug/logfilter/example2.out.expected (renamed from debug/logfilter/example2.out.expected)0
-rw-r--r--tools/debug/logfilter/example3.in (renamed from debug/logfilter/example3.in)0
-rw-r--r--tools/debug/logfilter/example3.out.expected (renamed from debug/logfilter/example3.out.expected)0
-rw-r--r--tools/debug/logfilter/example4.in (renamed from debug/logfilter/example4.in)0
-rw-r--r--tools/debug/logfilter/example4.out.expected (renamed from debug/logfilter/example4.out.expected)0
-rw-r--r--tools/debug/logfilter/example5.in (renamed from debug/logfilter/example5.in)0
-rw-r--r--tools/debug/logfilter/example5.out.expected (renamed from debug/logfilter/example5.out.expected)0
-rw-r--r--tools/debug/logfilter/example6.in (renamed from debug/logfilter/example6.in)0
-rw-r--r--tools/debug/logfilter/example6.out.expected (renamed from debug/logfilter/example6.out.expected)0
-rw-r--r--tools/debug/logfilter/example7.in (renamed from debug/logfilter/example7.in)0
-rw-r--r--tools/debug/logfilter/example7.out.expected (renamed from debug/logfilter/example7.out.expected)0
-rw-r--r--tools/debug/logfilter/example8.in (renamed from debug/logfilter/example8.in)0
-rw-r--r--tools/debug/logfilter/example8.out.expected (renamed from debug/logfilter/example8.out.expected)0
-rw-r--r--tools/debug/logfilter/main.go (renamed from debug/logfilter/main.go)0
-rw-r--r--tools/debug/logfilter/main_test.go (renamed from debug/logfilter/main_test.go)0
-rw-r--r--tools/debug/net.py (renamed from debug/net.py)0
-rw-r--r--tools/debug/showchains.py (renamed from debug/showchains.py)0
-rw-r--r--tools/misc/README.md31
-rw-r--r--tools/misc/convertAddress.go51
30 files changed, 105 insertions, 2 deletions
diff --git a/README.md b/README.md
index a5c0487c3..664bd207d 100644
--- a/README.md
+++ b/README.md
@@ -164,13 +164,14 @@ The following packages allow developers to interface with the Algorand system:
- `cmd/catchupsrv` ([README](cmd/catchupsrv/README.md)) is a tool to
assist with processing historic blocks on a new node.
- `libgoal` exports a Go interface useful for developers of Algorand clients.
- - `debug` holds secondary commands which assist developers during debugging.
+ - `tools` ([README](tools/README.md)) various tools and utilities without a better place to go.
+ - `tools/debug` holds secondary commands which assist developers during debugging.
+ - `tools/misc` ([README](tools/misc/README.md)) small tools that are sometimes handy in a pinch.
The following packages contain tools to help Algorand developers deploy networks
of their own:
- `nodecontrol`
- - `tools`
- `docker`
- `commandandcontrol` ([README](test/commandandcontrol/README.md)) is a tool to
automate a network of algod instances.
diff --git a/tools/README.md b/tools/README.md
new file mode 100644
index 000000000..b8394ac77
--- /dev/null
+++ b/tools/README.md
@@ -0,0 +1,20 @@
+# Misfit Tools
+
+Various tools and utilities that don't have a better place to go.
+
+### debug
+
+Tools for debugging algod. These were really useful before launch when we spent a lot of time analyzing node behavior, but aren't needed as much recently.
+
+### misc
+
+Small tools that are useful in niche situations.
+
+### network
+
+This is a go package used by some of the CLI commands.
+
+### TEAL
+
+Some of the earliest tools we built for working with TEAL programs. A lot of these are workarounds for things that no longer need to be worked around, but these are still nice examples of what TEAL can do.
+
diff --git a/debug/carpenter/main.go b/tools/debug/carpenter/main.go
index 6f66211f1..6f66211f1 100644
--- a/debug/carpenter/main.go
+++ b/tools/debug/carpenter/main.go
diff --git a/debug/coroner/main.go b/tools/debug/coroner/main.go
index 57acf0b38..57acf0b38 100644
--- a/debug/coroner/main.go
+++ b/tools/debug/coroner/main.go
diff --git a/debug/doberman/logo.go b/tools/debug/doberman/logo.go
index dbd85cffb..dbd85cffb 100644
--- a/debug/doberman/logo.go
+++ b/tools/debug/doberman/logo.go
diff --git a/debug/doberman/main.go b/tools/debug/doberman/main.go
index e44609eb4..e44609eb4 100644
--- a/debug/doberman/main.go
+++ b/tools/debug/doberman/main.go
diff --git a/debug/genconsensusconfig/main.go b/tools/debug/genconsensusconfig/main.go
index 850781f98..850781f98 100644
--- a/debug/genconsensusconfig/main.go
+++ b/tools/debug/genconsensusconfig/main.go
diff --git a/debug/jslog b/tools/debug/jslog
index 540ebb66c..540ebb66c 100755
--- a/debug/jslog
+++ b/tools/debug/jslog
diff --git a/debug/logfilter/example1.in b/tools/debug/logfilter/example1.in
index aba082013..aba082013 100644
--- a/debug/logfilter/example1.in
+++ b/tools/debug/logfilter/example1.in
diff --git a/debug/logfilter/example1.out.expected b/tools/debug/logfilter/example1.out.expected
index 7bafe7b35..7bafe7b35 100644
--- a/debug/logfilter/example1.out.expected
+++ b/tools/debug/logfilter/example1.out.expected
diff --git a/debug/logfilter/example2.in b/tools/debug/logfilter/example2.in
index fbf835f59..fbf835f59 100644
--- a/debug/logfilter/example2.in
+++ b/tools/debug/logfilter/example2.in
diff --git a/debug/logfilter/example2.out.expected b/tools/debug/logfilter/example2.out.expected
index 767f8b1d1..767f8b1d1 100644
--- a/debug/logfilter/example2.out.expected
+++ b/tools/debug/logfilter/example2.out.expected
diff --git a/debug/logfilter/example3.in b/tools/debug/logfilter/example3.in
index 54db2210c..54db2210c 100644
--- a/debug/logfilter/example3.in
+++ b/tools/debug/logfilter/example3.in
diff --git a/debug/logfilter/example3.out.expected b/tools/debug/logfilter/example3.out.expected
index e20c090b9..e20c090b9 100644
--- a/debug/logfilter/example3.out.expected
+++ b/tools/debug/logfilter/example3.out.expected
diff --git a/debug/logfilter/example4.in b/tools/debug/logfilter/example4.in
index fb04351de..fb04351de 100644
--- a/debug/logfilter/example4.in
+++ b/tools/debug/logfilter/example4.in
diff --git a/debug/logfilter/example4.out.expected b/tools/debug/logfilter/example4.out.expected
index b85960134..b85960134 100644
--- a/debug/logfilter/example4.out.expected
+++ b/tools/debug/logfilter/example4.out.expected
diff --git a/debug/logfilter/example5.in b/tools/debug/logfilter/example5.in
index 599b6e0ba..599b6e0ba 100644
--- a/debug/logfilter/example5.in
+++ b/tools/debug/logfilter/example5.in
diff --git a/debug/logfilter/example5.out.expected b/tools/debug/logfilter/example5.out.expected
index 046e2dd2e..046e2dd2e 100644
--- a/debug/logfilter/example5.out.expected
+++ b/tools/debug/logfilter/example5.out.expected
diff --git a/debug/logfilter/example6.in b/tools/debug/logfilter/example6.in
index f34549897..f34549897 100644
--- a/debug/logfilter/example6.in
+++ b/tools/debug/logfilter/example6.in
diff --git a/debug/logfilter/example6.out.expected b/tools/debug/logfilter/example6.out.expected
index a69592034..a69592034 100644
--- a/debug/logfilter/example6.out.expected
+++ b/tools/debug/logfilter/example6.out.expected
diff --git a/debug/logfilter/example7.in b/tools/debug/logfilter/example7.in
index 0953dd539..0953dd539 100644
--- a/debug/logfilter/example7.in
+++ b/tools/debug/logfilter/example7.in
diff --git a/debug/logfilter/example7.out.expected b/tools/debug/logfilter/example7.out.expected
index c7df1d1a6..c7df1d1a6 100644
--- a/debug/logfilter/example7.out.expected
+++ b/tools/debug/logfilter/example7.out.expected
diff --git a/debug/logfilter/example8.in b/tools/debug/logfilter/example8.in
index b538811e0..b538811e0 100644
--- a/debug/logfilter/example8.in
+++ b/tools/debug/logfilter/example8.in
diff --git a/debug/logfilter/example8.out.expected b/tools/debug/logfilter/example8.out.expected
index 68ea01a6b..68ea01a6b 100644
--- a/debug/logfilter/example8.out.expected
+++ b/tools/debug/logfilter/example8.out.expected
diff --git a/debug/logfilter/main.go b/tools/debug/logfilter/main.go
index 265c501fe..265c501fe 100644
--- a/debug/logfilter/main.go
+++ b/tools/debug/logfilter/main.go
diff --git a/debug/logfilter/main_test.go b/tools/debug/logfilter/main_test.go
index a68007374..a68007374 100644
--- a/debug/logfilter/main_test.go
+++ b/tools/debug/logfilter/main_test.go
diff --git a/debug/net.py b/tools/debug/net.py
index 037255f77..037255f77 100644
--- a/debug/net.py
+++ b/tools/debug/net.py
diff --git a/debug/showchains.py b/tools/debug/showchains.py
index 20cb1080f..20cb1080f 100644
--- a/debug/showchains.py
+++ b/tools/debug/showchains.py
diff --git a/tools/misc/README.md b/tools/misc/README.md
new file mode 100644
index 000000000..8a94102b0
--- /dev/null
+++ b/tools/misc/README.md
@@ -0,0 +1,31 @@
+# Misc Tools
+
+Collection of various tools that are useful enough to save, but niche enough that they don't belong in goal.
+
+
+### convertAddress
+
+It's sometimes useful to convert addresses between the public "Stripped Base32 /w checksum" format, and the Base64 encoded 32 byte format. This tool converts the two formats.
+
+There is only very minor error checking, results from this tool to not ensure valid inputs.
+
+```sh
+# Address to Base64 encoded bytes.
+~$ go run convertAddress.go -addr E33YVTQNYH2BHI33OCYL7JQQSEMXD4EN74CZQ37FC6EZFHIBCNWOWXIZ5M
+JveKzg3B9BOje3Cwv6YQkRlx8I3/BZhv5ReJkp0BE2w=
+
+# Base64 encoded bytes to Address.
+~$ go run convertAddress.go -addr JveKzg3B9BOje3Cwv6YQkRlx8I3/BZhv5ReJkp0BE2w=
+E33YVTQNYH2BHI33OCYL7JQQSEMXD4EN74CZQ37FC6EZFHIBCNWOWXIZ5M
+
+```
+
+If you want to run it more than once, it may be useful to compile a binary rather than building with `go run` on each invokation:
+```sh
+# Build binary.
+~$ go build convertAddress.go
+
+# Use binary.
+~$ ./convertAddress -addr JveKzg3B9BOje3Cwv6YQkRlx8I3/BZhv5ReJkp0BE2w=
+E33YVTQNYH2BHI33OCYL7JQQSEMXD4EN74CZQ37FC6EZFHIBCNWOWXIZ5M
+```
diff --git a/tools/misc/convertAddress.go b/tools/misc/convertAddress.go
new file mode 100644
index 000000000..90cdf74b1
--- /dev/null
+++ b/tools/misc/convertAddress.go
@@ -0,0 +1,51 @@
+// Copyright (C) 2019-2021 Algorand, Inc.
+// This file is part of go-algorand
+//
+// go-algorand is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// go-algorand is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with go-algorand. If not, see <https://www.gnu.org/licenses/>.
+
+package main
+
+import (
+ "encoding/base64"
+ "flag"
+ "fmt"
+
+ "github.com/algorand/go-algorand/data/basics"
+)
+
+func main() {
+ var addrInput string
+ flag.StringVar(&addrInput, "addr", "", "base64/algorand address to convert to the other")
+ flag.Parse()
+
+ if addrInput == "" {
+ fmt.Println("provide input with '-addr' flag.")
+ return
+ }
+
+ addrBytes, err := base64.StdEncoding.DecodeString(addrInput)
+ if err != nil {
+ // Failed to base64 decode, check for Algorand address format.
+ a, err := basics.UnmarshalChecksumAddress(addrInput)
+ if err != nil {
+ fmt.Println(err)
+ return
+ }
+ fmt.Println(base64.StdEncoding.EncodeToString(a[:]))
+ return
+ }
+ var addr basics.Address
+ copy(addr[:], addrBytes)
+ fmt.Println(addr.String())
+}