New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't attempt to vote/revoke without the private key #2062
Conversation
This error is commonly seen on ticketbuyer wallets which will attempt to revoke any missed tickets, even though an importing voting xpub account prevents access to the private keys to do so. This is not an error, and should be detected up front before ever constructing the unsigned vote/revocation. When the private key is recorded by the wallet, but the wallet or account is locked, the wallet will still error when failing to sign the revocation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works well for me.
id, err := addressID(addr) | ||
if err != nil { | ||
return false, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to return err here because we were expecting P2PK or P2PKH addr which should have an ID? ofc not sure tho.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressID
uses a check for Hash160er
which also supports P2SH, Schnorr, etc. This will really only err for a completely unknown address type, in which case we don`t have the private key anyway, so this fulfills the API for this func.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noting that checking haveKey
is sufficient for all currently existing uses of hasVotingAuthority
, but I guess it could be useful to differentiate between owned && !haveKey
vs owned && haveKey
in the future.
id, err := addressID(addr) | ||
if err != nil { | ||
return false, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressID
uses a check for Hash160er
which also supports P2SH, Schnorr, etc. This will really only err for a completely unknown address type, in which case we don`t have the private key anyway, so this fulfills the API for this func.
This error is commonly seen on ticketbuyer wallets which will attempt
to revoke any missed tickets, even though an importing voting xpub
account prevents access to the private keys to do so. This is not an
error, and should be detected up front before ever constructing the
unsigned vote/revocation.
When the private key is recorded by the wallet, but the wallet or
account is locked, the wallet will still error when failing to sign
the revocation.