Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

crypto.gno

0.40 Kb · 20 lines
 1package testutils
 2
 3import "crypto/bech32"
 4
 5func TestAddress(name string) address {
 6	if len(name) > 20 {
 7		panic("address name cannot be greater than 20 bytes")
 8	}
 9	addr := []byte("____________________")
10	copy(addr[:], name)
11	converted, err := bech32.ConvertBits(addr, 8, 5, true)
12	if err != nil {
13		panic(err)
14	}
15	enc, err := bech32.Encode("g", converted)
16	if err != nil {
17		panic(err)
18	}
19	return address(enc)
20}