Comments (4)
basics.ChecksumAddress
doesn't need to exist; the checksumming functionality can be brought into the MarshalText
/ UnmarshalText
/ String
methods of basics.Address
. This should allow most of the code in inspect.go
to be deleted.
For context, whenever we represent an address as text, we compute and append a checksum -- this lets us catch errors if someone mistypes an address. When using addresses internally we don't bother keeping around the checksum; for example, when sending a transaction over the wire, we don't include the checksum in the binary (msgpack) representation of the sender address. The checksum is cheap enough that it's fine to recompute it if we ever need to display an address to a user.
At one point we thought it would be a good idea to have separate types for the internal / external representations of addresses -- basics.Address
and basics.ChecksumAddress
. But this turns out to add boilerplate (have to cast to a ChecksumAddress whenever displaying address to user) and make it easy to accidentally display to the user a non-checksummed address (by forgetting the cast).
Whenever we're representing an address as text (and only when we're representing an address as text), we want a checksum. So there don't need to be two separate types -- calculating the checksum should just happen inside the MarshalText
, UnmarshalText
, and String
methods of basics.Address
. Then basics.ChecksumAddress
can be removed and all uses of basics.ChecksumAddress
in our codebase can be replaced with basics.Address
.
inspect.go
just makes types identical to other types defined elsewhere but with checksumAddress
where other types have Address
so that e.g., the sender address of a transaction will print with the checksum. If basics.Address
had a String
method that added the checksum then fmt.Printf("%v", transaction)
would already include checksums and most of the boilerplate in inspect.go
could be removed.
(As a sidenote, I think the multisig-related code in crypto.go
might still require these boilerplate wrappers because multisigs in some places use crypto.PublicKey
instead of basics.Address
. Multisig internals definitely could use some cleaning-up, but that's out of scope of this particular issue.)
from go-algorand.
(not sure crypto.PublicKey
is an issue - it's a fixed array? Can you elaborate)
from go-algorand.
crypto.PublicKey
doesn't (and probably shoudln't) include base32 or checksum printing code.
Multisigs include crypto.PublicKey
s instead of basics.Address
es because (among other reasons) the basics
package imports the crypto
package and so the crypto
package can't import the basics
package. Changing that is probably out of scope of this issue.
So inspect.go
will probably still need to contain code to pretty-print multisigs. However, we should be able to get rid of the non-multisig boilerplate like inspectTransaction
, inspectTxnHeader
, inspectPaymentTxnFields
, etc.
from go-algorand.
Fixed by PR #102 (thanks zacharyestep!)
from go-algorand.
Related Issues (20)
- Leverage DHT for Peer-based Discovery/Advertisements HOT 1
- put agreement DB in hot storage tier HOT 1
- Getting blank transaction array when `pending_transaction_info()` is executed. HOT 1
- Official docker images are incompatible with windows server workers on github actions HOT 3
- Build: Flaky Ledger Catchup StateProof Verification Test
- The `DisableAPIAuth` config option causes requests to error if any auth token is present HOT 2
- As a beginner, how should I build my own chain? HOT 3
- The security vulnerability bounty page is "Not Found"
- Missing LedgerStateDelta from OAS spec (and therefore documentation and other SDKs apart from Go) HOT 1
- Measure consensus Nakamoto coefficient HOT 5
- goal should make extra information provided in some API requests available HOT 1
- Documentation and Config Generation: non-archival relays should retain last 20K or more blocks
- There are 11 pages of GitHub issues, some as old as 2019. Let's clean this up? HOT 1
- simulate fails with empty signature on a rekeyed account HOT 15
- Catchpoint is very slow HOT 3
- Add option to store and retrieve deltas HOT 2
- Node's ready status is incorrect while the node is starting HOT 1
- Buggy test?
- increase max lsig program size HOT 5
- Add access to incentive related consensus parameters HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-algorand.