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

Fix crash when import watch-only wallet and click send button #200

Merged
merged 7 commits into from
Oct 27, 2023

Conversation

JustinBeBoy
Copy link
Collaborator

@JustinBeBoy JustinBeBoy commented Oct 24, 2023

Resolve #182

This PR fix:

  • App crash when import only watch-only wallet.
  • App crash when click send button
  • App crash when import mixed account of watch-only wallet
  • App crash when delete wallet.

pr1

@dreacot
Copy link
Member

dreacot commented Oct 24, 2023

launching a fresh instance of cryptopower i get this error

$ go run . --network=testnet
Config file (/home/kennedy/.cryptopower/cryptopower.conf) does not exist. Using defaults.
2023-10-24 11:08:25.572 [INF] DLWL: Starting check and remove all dir of deleted wallets....
2023-10-24 11:08:25.572 [ERR] DLWL: can't read DCR root wallet type: open /home/kennedy/.cryptopower/testnet/testnet3/dcr: no such file or directory
2023-10-24 11:08:25.572 [INF] DLWL: Loaded 0 wallets
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x10de1ce]

goroutine 1 [running]:
github.com/crypto-power/cryptopower/libwallet.(*AssetsManager).GetCurrencyConversionExchange(...)
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/libwallet/assets_config.go:141
github.com/crypto-power/cryptopower/libwallet.(*AssetsManager).initRateSource(0xc000511780)
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/libwallet/assets_manager.go:193 +0x10e
github.com/crypto-power/cryptopower/libwallet.NewAssetsManager({0xc00050f780?, 0x7?}, {0x186c689, 0x3}, {0x18a5e86, 0x25}, {0xc000446d20, 0x28}, {0x1871ea3, 0x7})
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/libwallet/assets_manager.go:172 +0x6c5
github.com/crypto-power/cryptopower/wallet.(*Wallet).InitAssetsManager(0xc000511700)
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/wallet/wallet.go:81 +0xbb
main.main()
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/main.go:77 +0x325
exit status 2

@dreacot
Copy link
Member

dreacot commented Oct 24, 2023

launching a fresh instance of cryptopower i get this error

$ go run . --network=testnet
Config file (/home/kennedy/.cryptopower/cryptopower.conf) does not exist. Using defaults.
2023-10-24 11:08:25.572 [INF] DLWL: Starting check and remove all dir of deleted wallets....
2023-10-24 11:08:25.572 [ERR] DLWL: can't read DCR root wallet type: open /home/kennedy/.cryptopower/testnet/testnet3/dcr: no such file or directory
2023-10-24 11:08:25.572 [INF] DLWL: Loaded 0 wallets
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x10de1ce]

goroutine 1 [running]:
github.com/crypto-power/cryptopower/libwallet.(*AssetsManager).GetCurrencyConversionExchange(...)
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/libwallet/assets_config.go:141
github.com/crypto-power/cryptopower/libwallet.(*AssetsManager).initRateSource(0xc000511780)
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/libwallet/assets_manager.go:193 +0x10e
github.com/crypto-power/cryptopower/libwallet.NewAssetsManager({0xc00050f780?, 0x7?}, {0x186c689, 0x3}, {0x18a5e86, 0x25}, {0xc000446d20, 0x28}, {0x1871ea3, 0x7})
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/libwallet/assets_manager.go:172 +0x6c5
github.com/crypto-power/cryptopower/wallet.(*Wallet).InitAssetsManager(0xc000511700)
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/wallet/wallet.go:81 +0xbb
main.main()
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/main.go:77 +0x325
exit status 2

this seems to be on master as well, but this would need to be fixed in order to test this PR as i need to import a watch only wallet on a fresh install of cryptopower

@JustinBeBoy
Copy link
Collaborator Author

launching a fresh instance of cryptopower i get this error

$ go run . --network=testnet
Config file (/home/kennedy/.cryptopower/cryptopower.conf) does not exist. Using defaults.
2023-10-24 11:08:25.572 [INF] DLWL: Starting check and remove all dir of deleted wallets....
2023-10-24 11:08:25.572 [ERR] DLWL: can't read DCR root wallet type: open /home/kennedy/.cryptopower/testnet/testnet3/dcr: no such file or directory
2023-10-24 11:08:25.572 [INF] DLWL: Loaded 0 wallets
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x10de1ce]

goroutine 1 [running]:
github.com/crypto-power/cryptopower/libwallet.(*AssetsManager).GetCurrencyConversionExchange(...)
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/libwallet/assets_config.go:141
github.com/crypto-power/cryptopower/libwallet.(*AssetsManager).initRateSource(0xc000511780)
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/libwallet/assets_manager.go:193 +0x10e
github.com/crypto-power/cryptopower/libwallet.NewAssetsManager({0xc00050f780?, 0x7?}, {0x186c689, 0x3}, {0x18a5e86, 0x25}, {0xc000446d20, 0x28}, {0x1871ea3, 0x7})
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/libwallet/assets_manager.go:172 +0x6c5
github.com/crypto-power/cryptopower/wallet.(*Wallet).InitAssetsManager(0xc000511700)
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/wallet/wallet.go:81 +0xbb
main.main()
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/main.go:77 +0x325
exit status 2

this seems to be on master as well, but this would need to be fixed in order to test this PR as i need to import a watch only wallet on a fresh install of cryptopower

even though it's not within the scope of this PR, I'll fix it

@dreacot
Copy link
Member

dreacot commented Oct 24, 2023

seems the issue has been resolved #202

@dreacot
Copy link
Member

dreacot commented Oct 24, 2023

@JustinBeBoy did you test this on a fresh install of cryptopower? cause that's how to detect the issue, it still happens

2023-10-24 17:38:42.444 [INF] DLWL: Loaded 0 wallets
2023-10-24 17:38:58.243 [INF] WLLT: Upgrading database from version 1 to 25
2023-10-24 17:39:00.939 [INF] DCR: Opened wallet
2023-10-24 17:39:00.945 [INF] SHWL: Created Watching Only Wallet
panic: assignment to entry in nil map

goroutine 39 [running]:
github.com/crypto-power/cryptopower/libwallet/assets/dcr.(*Asset).AddAccountMixerNotificationListener(0xc000648680, {0x1ff5578?, 0xc0000d4800}, {0x1877f8b, 0x8})
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/libwallet/assets/dcr/account_mixer.go:36 +0xf0
github.com/crypto-power/cryptopower/ui/page/root.(*OverviewPage).listenForMixerNotifications(0xc0000d4800)
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/page/root/overview_page.go:1187 +0x22c
github.com/crypto-power/cryptopower/ui/page/root.(*OverviewPage).OnNavigatedTo(0xc0000d4800)
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/page/root/overview_page.go:217 +0x22f
github.com/crypto-power/cryptopower/app.(*PageStack).Push(0xc003742d20, {0x1ffe6d8, 0xc0000d4800}, {0x2001700, 0xc000554090})
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/app/pagestack.go:67 +0x538
github.com/crypto-power/cryptopower/app.(*MasterPage).Display(0xc000554090, {0x1ffe6d8?, 0xc0000d4800?})
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/app/masterpage.go:46 +0x39
github.com/crypto-power/cryptopower/ui/page/root.(*HomePage).OnNavigatedTo(0xc000628000)
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/page/root/home_page.go:137 +0x109
github.com/crypto-power/cryptopower/app.(*PageStack).Push(0xc0001c99e0, {0x1ffe648, 0xc000628000}, {0x2001750, 0xc0001c9a10})
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/app/pagestack.go:67 +0x538
github.com/crypto-power/cryptopower/app.(*SimpleWindowNavigator).Display(0xc0001c9a10, {0x1ffe648?, 0xc000628000?})
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/app/window.go:49 +0x39
github.com/crypto-power/cryptopower/ui/page/root.(*CreateWallet).walletCreationSuccessCallback(0xc00157d500)
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/page/root/wallet_setup_page.go:636 +0x7a
github.com/crypto-power/cryptopower/ui/page/root.(*CreateWallet).HandleUserInteractions.func3()
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/page/root/wallet_setup_page.go:554 +0x518
created by github.com/crypto-power/cryptopower/ui/page/root.(*CreateWallet).HandleUserInteractions
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/page/root/wallet_setup_page.go:517 +0x745
exit status 2

@JustinBeBoy
Copy link
Collaborator Author

JustinBeBoy commented Oct 25, 2023

@JustinBeBoy did you test this on a fresh install of cryptopower? cause that's how to detect the issue, it still happens

2023-10-24 17:38:42.444 [INF] DLWL: Loaded 0 wallets
2023-10-24 17:38:58.243 [INF] WLLT: Upgrading database from version 1 to 25
2023-10-24 17:39:00.939 [INF] DCR: Opened wallet
2023-10-24 17:39:00.945 [INF] SHWL: Created Watching Only Wallet
panic: assignment to entry in nil map

goroutine 39 [running]:
github.com/crypto-power/cryptopower/libwallet/assets/dcr.(*Asset).AddAccountMixerNotificationListener(0xc000648680, {0x1ff5578?, 0xc0000d4800}, {0x1877f8b, 0x8})
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/libwallet/assets/dcr/account_mixer.go:36 +0xf0
github.com/crypto-power/cryptopower/ui/page/root.(*OverviewPage).listenForMixerNotifications(0xc0000d4800)
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/page/root/overview_page.go:1187 +0x22c
github.com/crypto-power/cryptopower/ui/page/root.(*OverviewPage).OnNavigatedTo(0xc0000d4800)
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/page/root/overview_page.go:217 +0x22f
github.com/crypto-power/cryptopower/app.(*PageStack).Push(0xc003742d20, {0x1ffe6d8, 0xc0000d4800}, {0x2001700, 0xc000554090})
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/app/pagestack.go:67 +0x538
github.com/crypto-power/cryptopower/app.(*MasterPage).Display(0xc000554090, {0x1ffe6d8?, 0xc0000d4800?})
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/app/masterpage.go:46 +0x39
github.com/crypto-power/cryptopower/ui/page/root.(*HomePage).OnNavigatedTo(0xc000628000)
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/page/root/home_page.go:137 +0x109
github.com/crypto-power/cryptopower/app.(*PageStack).Push(0xc0001c99e0, {0x1ffe648, 0xc000628000}, {0x2001750, 0xc0001c9a10})
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/app/pagestack.go:67 +0x538
github.com/crypto-power/cryptopower/app.(*SimpleWindowNavigator).Display(0xc0001c9a10, {0x1ffe648?, 0xc000628000?})
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/app/window.go:49 +0x39
github.com/crypto-power/cryptopower/ui/page/root.(*CreateWallet).walletCreationSuccessCallback(0xc00157d500)
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/page/root/wallet_setup_page.go:636 +0x7a
github.com/crypto-power/cryptopower/ui/page/root.(*CreateWallet).HandleUserInteractions.func3()
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/page/root/wallet_setup_page.go:554 +0x518
created by github.com/crypto-power/cryptopower/ui/page/root.(*CreateWallet).HandleUserInteractions
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/page/root/wallet_setup_page.go:517 +0x745
exit status 2

I have tested, seem like your wallet have mixed account, I will test that case

@dreacot
Copy link
Member

dreacot commented Oct 25, 2023

clicking the send button for the first time caused a crash
however opening the app again and clicking the send button shows a modal.

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x60 pc=0x12eb8b4]

goroutine 10 [running]:
github.com/crypto-power/cryptopower/ui/page/send.(*Page).showBalanceAfterSend(0xc0000be300?)
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/page/send/page.go:455 +0x34
github.com/crypto-power/cryptopower/ui/page/send.(*Page).validateAndConstructTx(0x0?)
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/page/send/page.go:341 +0x65
github.com/crypto-power/cryptopower/ui/page/send.NewSendPage.func2()
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/page/send/page.go:138 +0x1d
github.com/crypto-power/cryptopower/ui/page/send.(*destination).handle(0xc0050d1c00)
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/page/send/send_destination.go:142 +0x65
github.com/crypto-power/cryptopower/ui/page/send.(*Page).HandleUserInteractions(0xc0000be300)
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/page/send/page.go:510 +0x2bd
github.com/crypto-power/cryptopower/ui/page/send.(*Page).Handle(0xc000478a00?)
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/page/send/page.go:603 +0xbb
github.com/crypto-power/cryptopower/ui.(*Window).handleFrameEvent(0xc000191680, {{0xc146710844bbd07f, 0x126d34640b, 0x2f08680}, {0x3f800000, 0x3f800000}, {0x320, 0x28a}, {0x0, 0x0, ...}, ...})
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/window.go:235 +0x171
github.com/crypto-power/cryptopower/ui.(*Window).HandleEvents(0xc000191680)
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/window.go:206 +0x2b9
main.main.func3()
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/main.go:110 +0x1d
created by main.main
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/main.go:108 +0x61b
exit status 2

app/masterpage.go Outdated Show resolved Hide resolved
app/masterpage.go Outdated Show resolved Hide resolved
app/masterpage.go Outdated Show resolved Hide resolved
@JustinBeBoy
Copy link
Collaborator Author

clicking the send button for the first time caused a crash however opening the app again and clicking the send button shows a modal.

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x60 pc=0x12eb8b4]

goroutine 10 [running]:
github.com/crypto-power/cryptopower/ui/page/send.(*Page).showBalanceAfterSend(0xc0000be300?)
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/page/send/page.go:455 +0x34
github.com/crypto-power/cryptopower/ui/page/send.(*Page).validateAndConstructTx(0x0?)
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/page/send/page.go:341 +0x65
github.com/crypto-power/cryptopower/ui/page/send.NewSendPage.func2()
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/page/send/page.go:138 +0x1d
github.com/crypto-power/cryptopower/ui/page/send.(*destination).handle(0xc0050d1c00)
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/page/send/send_destination.go:142 +0x65
github.com/crypto-power/cryptopower/ui/page/send.(*Page).HandleUserInteractions(0xc0000be300)
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/page/send/page.go:510 +0x2bd
github.com/crypto-power/cryptopower/ui/page/send.(*Page).Handle(0xc000478a00?)
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/page/send/page.go:603 +0xbb
github.com/crypto-power/cryptopower/ui.(*Window).handleFrameEvent(0xc000191680, {{0xc146710844bbd07f, 0x126d34640b, 0x2f08680}, {0x3f800000, 0x3f800000}, {0x320, 0x28a}, {0x0, 0x0, ...}, ...})
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/window.go:235 +0x171
github.com/crypto-power/cryptopower/ui.(*Window).HandleEvents(0xc000191680)
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/window.go:206 +0x2b9
main.main.func3()
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/main.go:110 +0x1d
created by main.main
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/main.go:108 +0x61b
exit status 2

I can't reproduce it, please explain step by step and the extended public key you use

@JustinBeBoy
Copy link
Collaborator Author

clicking the send button for the first time caused a crash however opening the app again and clicking the send button shows a modal.

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x60 pc=0x12eb8b4]

goroutine 10 [running]:
github.com/crypto-power/cryptopower/ui/page/send.(*Page).showBalanceAfterSend(0xc0000be300?)
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/page/send/page.go:455 +0x34
github.com/crypto-power/cryptopower/ui/page/send.(*Page).validateAndConstructTx(0x0?)
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/page/send/page.go:341 +0x65
github.com/crypto-power/cryptopower/ui/page/send.NewSendPage.func2()
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/page/send/page.go:138 +0x1d
github.com/crypto-power/cryptopower/ui/page/send.(*destination).handle(0xc0050d1c00)
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/page/send/send_destination.go:142 +0x65
github.com/crypto-power/cryptopower/ui/page/send.(*Page).HandleUserInteractions(0xc0000be300)
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/page/send/page.go:510 +0x2bd
github.com/crypto-power/cryptopower/ui/page/send.(*Page).Handle(0xc000478a00?)
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/page/send/page.go:603 +0xbb
github.com/crypto-power/cryptopower/ui.(*Window).handleFrameEvent(0xc000191680, {{0xc146710844bbd07f, 0x126d34640b, 0x2f08680}, {0x3f800000, 0x3f800000}, {0x320, 0x28a}, {0x0, 0x0, ...}, ...})
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/window.go:235 +0x171
github.com/crypto-power/cryptopower/ui.(*Window).HandleEvents(0xc000191680)
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/ui/window.go:206 +0x2b9
main.main.func3()
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/main.go:110 +0x1d
created by main.main
        /home/kennedy/Projects/src/github.com/cryptopower/cryptopower/main.go:108 +0x61b
exit status 2

I can't reproduce it, please explain step by step and the extended public key you use

After a lot of test, I have found the problem

Comment on lines +61 to +63
if len(s.items) == 0 {
return D{}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i see no harm in showing the asset slider for a watch only wallet

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or is a watch only wallet's balance not calculated as part of the slider?

if it's not then ignore this

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or is a watch only wallet's balance not calculated as part of the slider?

if it's not then ignore this

Exactly, calculate total assets balance not include watch-only wallet, additional it causes crash app

ui/values/localizable/en.go Outdated Show resolved Hide resolved
@dreacot dreacot merged commit f226afd into crypto-power:master Oct 27, 2023
@JustinBeBoy JustinBeBoy deleted the crash_navi branch March 15, 2024 03:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Trying to import watch only wallet crashes the app
2 participants