cashubtc / cashu-feni

A Cashu mint and wallet implementation in Golang
MIT License
36 stars 13 forks source link

panic in send command #52

Closed elnosh closed 1 year ago

elnosh commented 1 year ago

What version of Go are you using (go version)?

$ go version
go version go1.21.0 linux/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
go env GOOS
linux
go env GOARCH
amd64

What did you do?

Running mint locally along with wallet. Pay lightning invoice to mint tokens. After paying invoice, ran balance command and getting expected balance. After confirming wallet had a balance, send command panicked. It seems it tried to access filteredKeySets slice which is not initialized.

in wallet: ~ balance You have balances in 1 keysets: Keysets: [MhH6M+GDd1/l] Balance: 76 sat URL: http://localhost:3338

~ send 10 MhH6M+GDd1/l panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]: github.com/cashubtc/cashu-feni/cmd/cashu/feni.send(0xc000259100?, {0xc000424560, 0x4?, 0xb2b9c2?}) /home/elnosh/Documents/cashu-feni/cmd/cashu/feni/send.go:126 +0x2f2 github.com/spf13/cobra.(Command).execute(0x1054600, {0xc000424500, 0x2, 0x2}) /home/elnosh/go/pkg/mod/github.com/spf13/cobra@v1.6.0/command.go:920 +0x863 github.com/spf13/cobra.(Command).ExecuteC(0x10531e0) /home/elnosh/go/pkg/mod/github.com/spf13/cobra@v1.6.0/command.go:1040 +0x38d github.com/spf13/cobra.(Command).Execute(...) /home/elnosh/go/pkg/mod/github.com/spf13/cobra@v1.6.0/command.go:968 github.com/cashubtc/cashu-feni/cmd/cashu/feni.CobraPrompt.Run.func1({0xc00015af18, 0x14}) /home/elnosh/Documents/cashu-feni/cmd/cashu/feni/prompt.go:75 +0x1a5 github.com/c-bata/go-prompt.(Prompt).Run(0xc00009c1b0) /home/elnosh/go/pkg/mod/github.com/c-bata/go-prompt@v0.2.6/prompt.go:84 +0x73f github.com/cashubtc/cashu-feni/cmd/cashu/feni.CobraPrompt.Run({0x10531e0, {0x109fa00, 0x3, 0x3}, 0xc26b70, 0x1, 0x0, 0x1, 0x0, 0x0, ...}) /home/elnosh/Documents/cashu-feni/cmd/cashu/feni/prompt.go:90 +0x18f main.main() /home/elnosh/Documents/cashu-feni/cmd/cashu/feni.go:59 +0x17f

What did you expect to see?

serialized token to be sent

What did you see instead?

wallet panic trying to access empty slice.