autonity / aut

A command-line RPC client for Autonity
MIT License
11 stars 10 forks source link

Can a keyfile specified in a command option override a keyfile specified in `.autrc` or should it error? #77

Closed cmjc closed 1 year ago

cmjc commented 1 year ago

Description

In autcli I can specify my signing key in 2 places:

I thought that if I had a key specified in .autrc and I then specified a key in the command using the key file command, then the key file specified in the command would be used and the one specified in .autrc be ignored.

However if the key file set in .autrc differs to that in a specified -k/--keyfile option it errors: ValueError: MAC mismatch.

Is this correct, or should a key specified as a command option override one set in .autrc?

// .autrc specifies alice.key. Specify bob.key in command to override. MAC mismatch error.

ubuntu@vps-c7c3e8c7:~/TEST/autcli$ aut validator bond --validator 0xA9F070101236476fe077F4A058C0C22E81b8A6C9 -k ./keystore/bob.key 1 | aut tx sign - | aut tx send -
(consider using 'KEYFILEPWD' env var).
Enter passphrase (or CTRL-d to exit): 
ValueError: MAC mismatch
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

// .autrc edited to specify bob.key. Specify bob.key in command to override. OK.

ubuntu@vps-c7c3e8c7:~/TEST/autcli$ nano .autrc
ubuntu@vps-c7c3e8c7:~/TEST/autcli$ aut validator bond --validator 0xA9F070101236476fe077F4A058C0C22E81b8A6C9 -k ./keystore/bob.key 1 | aut tx sign - | aut tx send -
(consider using 'KEYFILEPWD' env var).
Enter passphrase (or CTRL-d to exit): 
0x06cf3051aa8792b8a2a39ce7579ebf36657e3e6d809ea3cf18805718c8fa9e99

// .autrc edited to specify bob.key. Remove bob.key in command. OK.

ubuntu@vps-c7c3e8c7:~/TEST/autcli$ aut validator bond --validator 0xA9F070101236476fe077F4A058C0C22E81b8A6C9  1 | aut tx sign - | aut tx send -
(consider using 'KEYFILEPWD' env var).
Enter passphrase (or CTRL-d to exit): 
0xd927fa405c5f5da86e1f9279417f6f7675b22a291f3477566bdcda4927e53cff
dtebbs commented 1 year ago

I thought that if I had a key specified in .autrc and I then specified a key in the command using the key file command, then the key file specified in the command would be used and the one specified in .autrc be ignored.

Yes, this is how it should behave. I'll look into this. Thanks.

dtebbs commented 1 year ago

Ah, I see the problem. You need to sign with the same keyfile, otherwise the "from" field in the tx and the signe account don't match.

cmjc commented 1 year ago

OK, thanks for the clarification. Closing.