Skip to content

Add MustParseAddress helper function

Luke Champine requested to merge unlockhash into master

This incorporates @geo-gs's work from !3335 (closed), adding a helper function that makes it easier to work with known-valid addresses.

The name of the function follows the "Must" convention in the Go standard library, seen in functions like template.Must and regexp.MustCompile. The "Must" prefix means, "Be careful: this function panics instead of returning an error."

Replacing the siafund unlock hashes with their corresponding address strings may cause some unease. I have manually verified that the strings are equivalent, but I can add a test (or perhaps better, a program) that proves this if so desired.

It occurs to me that it would also be useful to have a MustSpecifier function, so that we could write (e.g.) MustSpecifier("LoopDownload") instead of types.Specifier{'L', 'o', 'o', 'p', 'D', 'o', 'w', 'n', 'l', 'o', 'a', 'd'}

Edited by Luke Champine

Merge request reports