spacemeshos / smcli

Spacemesh command-line tool
https://spacemesh.io/
MIT License
8 stars 9 forks source link

Spacemesh wallet address format #38

Closed lrettig closed 10 months ago

lrettig commented 1 year ago

This tool currently allows generation and display of public keys, but not Spacemesh account addresses in the bech32 format that can, e.g., be used as a coinbase address for receiving rewards in the protocol. Add this conversion:

See the addressgen tool added here: https://github.com/spacemeshos/go-spacemesh/pull/4276

0xjac commented 10 months ago

Happy to tackle this to. Looking at https://github.com/spacemeshos/spacemesh-sdk/issues/10 and spacemeshos/address, I'm not sure where the address logic should be located. Should it be left in spacemeshos/address and the having smcli and the sdk use it, or should the address logic be moved into the sdk and then have smcli use the sdk directly?

lrettig commented 10 months ago

This isn't as simple as it looks. https://github.com/spacemeshos/address contains some basic utilities but the core logic to calculate addresses lives here: https://github.com/spacemeshos/go-spacemesh/blob/a49921453d7ab7a4672194e98a41b58f17900d8c/genvm/core/hash.go#L18

It'd be nice to have this in Rust in the SDK, but at the moment it's pretty tightly coupled to go-spacemesh (CC @dshulyak). I definitely see value in having a Rust version of this and making it available over the CFFI. Note that it will require bringing in the SCALE codec -- https://github.com/paritytech/parity-scale-codec will likely work.

I don't think we should add this to the SDK until we've figured out, e.g., https://github.com/spacemeshos/go-spacemesh/issues/3984. For now let's just bring in this logic from the existing Go code (linked above).

I may need to do this today anyway as I'm adding some stuff here, give me a day or two.

0xjac commented 10 months ago

For now let's just bring in this logic from the existing Go code (linked above).

I may need to do this today anyway as I'm adding some stuff here, give me a day or two.

I'm happy to just port that logic here and now. You're then free to use it or not. :wink: