Skip to content
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

account number in keybase is not the same as account number in tx builder #1583

Closed
NicolasMahe opened this issue Jan 5, 2020 · 0 comments · Fixed by #1598
Closed

account number in keybase is not the same as account number in tx builder #1583

NicolasMahe opened this issue Jan 5, 2020 · 0 comments · Fixed by #1598
Assignees
Labels
bug Something isn't working

Comments

@NicolasMahe
Copy link
Member

NicolasMahe commented Jan 5, 2020

The account number in keybase is not the same as account number in tx builder.
The first one, is used in the hd path with the account index to derive the public key from the mnemonic.
As opposed as the second, that is define when the account receive some token..

So, we need to update the engine the get the account number from the function auth.NewAccountRetriever(c).GetAccount(c.acc.GetAddress()) and pass it to the TxBuilder as a parameter.

File cosmos/client.go#207

- txBuilder := NewTxBuilder(sequence, c.kb, c.chainID)
+ txBuilder := NewTxBuilder(c.acc.GetAccountNumber(), sequence, c.kb, c.chainID)

File cosmos/txbuilder.go#19

- func NewTxBuilder(accSeq uint64, kb keys.Keybase, chainID string) TxBuilder {
+ func NewTxBuilder(accNumber uint64, accSeq uint64, kb keys.Keybase, chainID string) TxBuilder {
	return TxBuilder{
		authtypes.NewTxBuilder(
			authutils.GetTxEncoder(codec.Codec),
-			AccNumber,
+			accNumber,

The config should also accept both the account number and account index in order to derive the account correctly accordingly to what the user could have possibility done! We will able to remove those 2 constants currently hardcoded in the codebase (expect for the dev account)


After some reflexion, i think we can simplify the account getter in cosmos/client.go. The issue is an account doesn't exist before it receives some tokens. I thought it will cause issues to sign transaction with account without token, but as we will enforce transaction fees, it means the account needs some token anyway.

@NicolasMahe NicolasMahe self-assigned this Jan 10, 2020
@NicolasMahe NicolasMahe added the bug Something isn't working label Jan 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant