givelotus / lotus-vase

A simple reference wallet for Lotus which supports mobile devices.
GNU General Public License v3.0
4 stars 2 forks source link

Invalid private key causing 'InvalidNetworkException' when loading stored private key #103

Closed chinitadelrey closed 3 years ago

chinitadelrey commented 3 years ago

Have gotten this error multiple times over the last week and in the new build... the issue seems to be in the encoding/decoding ? of the private key from file.

Copying and pasting the same phrase from save seed into import seed would remove this error.

But afterwards we get another issue with the jsonrpc requests, #104.

Notice the private key starts with a 2 not a K or L, which is what I think is breaking it:

(truncated printed list of my other private keys) 
I/flutter ( 4324): 2C9Cg9zq7rjFYvuNd3JAmPoAsAEbmv42yuotFYiR3vJuXQnvqBns
E/flutter ( 4324): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: Instance of 'InvalidNetworkException'

full trace:

E/flutter (26606): #0      new BCHPrivateKey.fromWIF (package:cashew/bitcoincash/privatekey.dart:155:11)
E/flutter (26606): #1      StoredKey.toKeyInfo (package:cashew/wallet/storage/keys.dart:72:31)
E/flutter (26606): #2      WalletModel.readKeysFromDisk.<anonymous closure> (package:cashew/viewmodel.dart:183:49)
E/flutter (26606): #3      MappedListIterable.elementAt (dart:_internal/iterable.dart:417:31)
E/flutter (26606): #4      ListIterator.moveNext (dart:_internal/iterable.dart:343:26)
E/flutter (26606): #5      new List.from (dart:core-patch/array_patch.dart:38:29)
E/flutter (26606): #6      new List.of (dart:core-patch/array_patch.dart:68:17)
E/flutter (26606): #7      ListIterable.toList (dart:_internal/iterable.dart:211:44)
E/flutter (26606): #8      WalletModel.readKeysFromDisk (package:cashew/viewmodel.dart:183:69)
E/flutter (26606): <asynchronous suspension>
E/flutter (26606): #9      WalletModel.readFromDisk (package:cashew/viewmodel.dart:122:24)
E/flutter (26606): <asynchronous suspension>
E/flutter (26606): #10     WalletModel.initializeModel (package:cashew/viewmodel.dart:49:31)
E/flutter (26606): #11     new WalletModel (package:cashew/viewmodel.dart:45:5)
E/flutter (26606): #12     _MainPageState.build.<anonymous closure> (package:cashew/main.dart:50:14)
E/flutter (26606): #13     _CreateInheritedProviderState.value (package:provider/src/inherited_provider.dart:641:35)
E/flutter (26606): #14     _InheritedProviderScopeElement.value (package:provider/src/inherited_provider.dart:504:33)
E/flutter (26606): #15     Provider.of (package:provider/src/provider.dart:267:29)
E/flutter (26606): #16     _MainPageState.build.<anonymous closure> (package:cashew/main.dart:52:34)
E/flutter (26606): #17     InheritedProvider.buildWithChild.<anonymous closure> (package:provider/src/inherited_provider.dart:163:44)
E/flutter (26606): #18     Builder.build (package:flutter/src/widgets/basic.dart:7183:48)
E/flutter (26606): #19     StatelessElement.build (package:flutter/src/widgets/framework.dart:4701:28)
E/flutter (26606): #20     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4627:15)
E/flutter (26606): #21     Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
E/flutter (26606): #22     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4606:5)
E/flutter (26606): #23     ComponentElement.mount (package:flutter/src/widgets/framework.dart:4601:5)
E/flutter (26606): #24     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
E/flutter (26606): #25     Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18)
E/flutter (26606): #26     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
E/flutter (26606): #27     _InheritedProviderScopeElement.performRebuild (package:provider/src/inherited_provider.dart:426:11)
E/flutter (26606): #28     Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
E/flutter (26606): #29     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4606:5)
E/flutter (26606): #30     ComponentElement.mount (package:flutter/src/widgets/framework.dart:4601:5)
E/flutter (26606): #31     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
E/flutter (26606): #32     Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18)
E/flutter (26606): #33     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
E/flutter (26606): #34     Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
E/flutter (26606): #35     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4606:5)
E/flutter (26606): #36     ComponentElement.mount (package:flutter/src/widgets/framework.dart:4601:5)
E/flutter (26606): #37     SingleChildWidgetElementMixin.mount (package:nested/nested.dart:223:11)
E/flutter (26606): #38     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
E/flutter (26606): #39     Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18)
E/flutter (26606): #40     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
E/flutter (26606): #41     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
E/flutter (26606): #42     Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
E/flutter (26606): #43     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4606:5)
E/flutter (26606): #44     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4791:11)
E/flutter (26606): #45     ComponentElement.mount (package:flutter/src/widgets/framework.dart:4601:5)
E/flutter (26606): #46     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
E/flutter (26606): #47     Element.updateChi
schancel commented 3 years ago

This might be something that @limonadev has fixed? Or maybe he broke it?

limonadev commented 3 years ago

@schancel This is the line that is probably causing the issue, but I think it's correct, the wifKey should have 32 bytes or 64 hex characters. Before my PR, it only was converted to base58 and the result could have less hex characters. That's what I fixed.

schancel commented 3 years ago

This error was caused by a bug in the electrum client regarding the responses to pings. Unrelated to key encodings.