diff --git a/.assets/00_demo_start.png b/.assets/00_demo_start.png index a1e9fa4..faeadf6 100644 Binary files a/.assets/00_demo_start.png and b/.assets/00_demo_start.png differ diff --git a/.assets/01_bob_alice_panes.png b/.assets/01_bob_alice_panes.png index 129d3e3..7f05e08 100644 Binary files a/.assets/01_bob_alice_panes.png and b/.assets/01_bob_alice_panes.png differ diff --git a/.assets/02-bob_view_alice_open.png b/.assets/02-bob_view_alice_open.png index 9b20cc5..7b9e206 100644 Binary files a/.assets/02-bob_view_alice_open.png and b/.assets/02-bob_view_alice_open.png differ diff --git a/.assets/03-alice_opens_400.png b/.assets/03-alice_opens_400.png index f01dd37..df2cb5b 100644 Binary files a/.assets/03-alice_opens_400.png and b/.assets/03-alice_opens_400.png differ diff --git a/.assets/04-alice_bob_wait.png b/.assets/04-alice_bob_wait.png index 4b077d8..fba594a 100644 Binary files a/.assets/04-alice_bob_wait.png and b/.assets/04-alice_bob_wait.png differ diff --git a/.assets/05-alice_bob_view_opened_channel.png b/.assets/05-alice_bob_view_opened_channel.png index 410b09c..bdbfe4a 100644 Binary files a/.assets/05-alice_bob_view_opened_channel.png and b/.assets/05-alice_bob_view_opened_channel.png differ diff --git a/.assets/06-alice_10_micropayments_20_each.png b/.assets/06-alice_10_micropayments_20_each.png index 24bd6fc..ae90297 100644 Binary files a/.assets/06-alice_10_micropayments_20_each.png and b/.assets/06-alice_10_micropayments_20_each.png differ diff --git a/.assets/07-alice_micropayments_done.png b/.assets/07-alice_micropayments_done.png index c6c4565..04bb4c2 100644 Binary files a/.assets/07-alice_micropayments_done.png and b/.assets/07-alice_micropayments_done.png differ diff --git a/.assets/08-bob_settles.png b/.assets/08-bob_settles.png index 7a0baa0..57ca055 100644 Binary files a/.assets/08-bob_settles.png and b/.assets/08-bob_settles.png differ diff --git a/.assets/09-show_final_balances.png b/.assets/09-show_final_balances.png index 86ecb13..fc6cdbe 100644 Binary files a/.assets/09-show_final_balances.png and b/.assets/09-show_final_balances.png differ diff --git a/.assets/10-alice_bob_restore.png b/.assets/10-alice_bob_restore.png new file mode 100644 index 0000000..2c00b68 Binary files /dev/null and b/.assets/10-alice_bob_restore.png differ diff --git a/.assets/11-alice_bob_restore_complete.png b/.assets/11-alice_bob_restore_complete.png new file mode 100644 index 0000000..7fc143e Binary files /dev/null and b/.assets/11-alice_bob_restore_complete.png differ diff --git a/.gitignore b/.gitignore index 8ac88b7..9682d5f 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,9 @@ # log files *.log +# database dir +channel_service/*-db + perun-nervos-demo # Dependency directories (remove the comment below to include it) diff --git a/README.md b/README.md index f8d34a7..1606574 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,7 @@ After a few seconds the transaction is confirmed on-chain and both parties were Let's use Alice to send ten micropayments of 20 CKBytes per payment to Bob via their channel. ![alice-send-micropayments](./.assets/06-alice_10_micropayments_20_each.png) - +**** We can observe the fact that multiple payments were issued by looking at the channels version number, which was incremented by ten, the amount of micropayments issued by Alice. ![micropayments-done](./.assets/07-alice_micropayments_done.png) @@ -128,3 +128,32 @@ Now we use Bob to settle the channel. After a few seconds the channels settlement is confirmed on-chain and we can view the updated balances for Bob and Alice. ![channel-settled](./.assets/09-show_final_balances.png) + + +## Restore Payment Channel +The database is store locally in `*-db` folders. + +Simulate an event of channel service shut down by stopping the channel service and the demo service on the second and third terminals. + +Restart the channel-services' terminal again. + +``` + $ cd ./channel_service + go run . +``` + +Restart Demo app. + +``` +./perun-nervos-demo +``` + +Navigate Restore the channel by selecting the `Restore Channel` button and confirm. + +![alice-and-bob-restore-channel](./.assets/10-alice_bob_restore.png) + +The old channel will be restored, identified by its ID. + +![alice-and-bob-restored-channel](./.assets/11-alice_bob_restore_complete.png) + +**Note:** If you want to restart a fresh demo, you will need to delete the database folders `*-db` in `channel_service` \ No newline at end of file diff --git a/channel_service/channel_service.go b/channel_service/channel_service.go index 2809a80..646816d 100644 --- a/channel_service/channel_service.go +++ b/channel_service/channel_service.go @@ -4,16 +4,13 @@ import ( "errors" "fmt" "log" - "math/rand" "net" "os" "os/signal" "syscall" - "time" "github.com/decred/dcrd/dcrec/secp256k1/v4" "github.com/nervosnetwork/ckb-sdk-go/v2/types" - "github.com/perun-network/perun-libp2p-wire/p2p" "google.golang.org/grpc" "perun.network/channel-service/rpc/proto" "perun.network/channel-service/service" @@ -22,6 +19,7 @@ import ( "perun.network/perun-ckb-backend/wallet/address" "perun.network/perun-ckb-backend/wallet/external" "perun.network/perun-nervos-demo/deployment" + "polycry.pt/poly-go/sortedkv/leveldb" ) const ( @@ -108,35 +106,24 @@ func main() { aliceWSC := setupWalletServiceClient(aliceWSSURL) bobWSC := setupWalletServiceClient(bobWSSURL) - wireAccA := p2p.NewRandomAccount(rand.New(rand.NewSource(time.Now().UnixNano()))) - wirenetA, err := p2p.NewP2PBus(wireAccA) + // Setup Alice + dbAlice, err := leveldb.LoadDatabase("./alice-db") if err != nil { - log.Fatalf("creating p2p net: %v", err) + log.Fatalf("loading database: %v", err) } - go wirenetA.Bus.Listen(wirenetA.Listener) - // AddressRessolver Alice - addrResolverA := service.NewRelayServerResolver(wireAccA) - if !addrResolverA.Address().Equal(wireAccA.Address()) { - log.Fatalf("address resolver address does not match account address") - } - - csA, err := service.NewChannelService(nil, wirenetA, network, rpcNodeURL, d, wireAccA.Address(), addrResolverA) + csA, err := service.NewChannelService(aliceWSC, network, rpcNodeURL, d, nil, dbAlice) if err != nil { log.Fatalf("creating channel service: %v", err) } - wireAccB := p2p.NewRandomAccount(rand.New(rand.NewSource(time.Now().UnixNano()))) - wirenetB, err := p2p.NewP2PBus(wireAccB) + // Setup Bob + dbBob, err := leveldb.LoadDatabase("./bob-db") if err != nil { - log.Fatalf("creating p2p net: %v", err) + log.Fatalf("loading database: %v", err) } - go wirenetB.Bus.Listen(wirenetB.Listener) - - // AddressRessolver Alice - addrResolverB := service.NewRelayServerResolver(wireAccB) - csB, err := service.NewChannelService(nil, wirenetB, network, rpcNodeURL, d, wireAccB.Address(), addrResolverB) + csB, err := service.NewChannelService(bobWSC, network, rpcNodeURL, d, nil, dbBob) if err != nil { log.Fatalf("creating channel service: %v", err) } @@ -164,6 +151,7 @@ func main() { // Channel to notify when servers are stopped done := make(chan bool, 1) + // Handle termination signal in a separate goroutine go func() { <-sigs fmt.Println("Shutting down gRPC servers...") @@ -178,7 +166,7 @@ func main() { // Start the servers go func() { - fmt.Printf("Starting Alice Channel Service Server at %s\n", hostA) + fmt.Printf("Starting Alice Channel Service Server at %s \n", hostA) err = sA.Serve(lisA) if err != nil { log.Fatalf("serving channel service: %v", err) @@ -186,7 +174,7 @@ func main() { }() go func() { - fmt.Printf("Starting Bob Channel Service Server at %s\n", hostB) + fmt.Printf("Starting Bob Channel Service Server at %s \n", hostB) err = sB.Serve(lisB) if err != nil { log.Fatalf("serving channel service: %v", err) diff --git a/client/client.go b/client/client.go index 07ae420..1153d9f 100644 --- a/client/client.go +++ b/client/client.go @@ -37,7 +37,7 @@ type WalletClient struct { Network types.Network assetRegister asset2.Register - channelService proto.ChannelServiceClient + ChannelService proto.ChannelServiceClient WalletServer *wallet_service.MyWalletService walletService proto.WalletServiceClient @@ -97,9 +97,10 @@ func NewWalletClient( rpcClient: balanceRPC, walletService: wsc, WalletServer: wss, - channelService: csc, + ChannelService: csc, } wss.SetOnUpdate(p.NotifyAllState) + go p.PollBalances() return p, nil } @@ -238,7 +239,7 @@ func (p *WalletClient) OpenChannel(peer gpwallet.Address, amounts map[gpchannel. } // Use channel service to send proposal - resp, err := p.channelService.OpenChannel(context.Background(), openChannelRequest) + resp, err := p.ChannelService.OpenChannel(context.Background(), openChannelRequest) if err != nil { log.Fatalf("Failed to open channel: %v", err) } @@ -253,6 +254,7 @@ func (p *WalletClient) OpenChannel(peer gpwallet.Address, amounts map[gpchannel. } func (p *WalletClient) SendPaymentToPeer(amounts map[gpchannel.Asset]float64) { + log.Println("SendPaymentToPeer called") if !p.HasOpenChannel() { return } @@ -283,7 +285,8 @@ func (p *WalletClient) SendPaymentToPeer(amounts map[gpchannel.Asset]float64) { State: protoUpdate, } - resp, err := p.channelService.UpdateChannel(context.Background(), updateChannelRequest) + log.Println("Sending payment to peer") + resp, err := p.ChannelService.UpdateChannel(context.Background(), updateChannelRequest) if err != nil { log.Fatalf("Failed to update channel: %v", err) } @@ -296,6 +299,7 @@ func (p *WalletClient) SendPaymentToPeer(amounts map[gpchannel.Asset]float64) { } func (p *WalletClient) Settle() { + log.Println("Settle called") if !p.HasOpenChannel() { return } @@ -304,7 +308,7 @@ func (p *WalletClient) Settle() { ChannelId: p.Channel.State().ID[:], } - resp, err := p.channelService.CloseChannel(context.Background(), closeChannelRequest) + resp, err := p.ChannelService.CloseChannel(context.Background(), closeChannelRequest) if err != nil { log.Fatalf("Failed to close channel: %v", err) } @@ -318,8 +322,38 @@ func (p *WalletClient) Settle() { } func (p *WalletClient) RestoreChannel() { - if p.HasOpenChannel() { + if !p.HasOpenChannel() { + + // Close Perun Client on Channel Service + log.Println("Closing perun client") + _, err := p.ChannelService.ClosePerunClient(context.Background(), &proto.ClosePerunClientRequest{}) + if err != nil { + log.Fatalf("failed to close perun client: %s", err) + } + + // Reinit Perun Client on Channel Service + log.Println("Creating perun client") + resp, err := p.ChannelService.NewPerunClient(context.Background(), &proto.NewPerunClientRequest{}) + if err != nil { + log.Fatalf("failed to create perun client: %s", err) + } + + if !resp.Accepted { + log.Fatalf("perun client creation rejected") + } + log.Println("Restoring channel") + // Restore the channel + resp2, err := p.ChannelService.RestoreChannels(context.Background(), &proto.RestoreChannelsRequest{}) + if err != nil { + log.Fatalf("Failed to restore channel: %v", err) + } + + if !resp2.Accepted { + log.Fatalf("Channel restore request was rejected") + } + log.Println("Channel restored") + return } log.Println("Channel is already online") diff --git a/go.mod b/go.mod index 1c7627e..60541e5 100644 --- a/go.mod +++ b/go.mod @@ -5,13 +5,12 @@ go 1.20 require ( github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 github.com/nervosnetwork/ckb-sdk-go/v2 v2.2.0 - github.com/perun-network/perun-libp2p-wire v0.0.0-20240604094050-faeb97e75f3c github.com/stretchr/testify v1.9.0 google.golang.org/grpc v1.59.0 perun.network/channel-service v0.0.0 perun.network/go-perun v0.11.0 perun.network/perun-ckb-backend v0.0.0-20240514141411-35bdf3afa166 - perun.network/perun-demo-tui v0.0.0-20240612133942-48e004fee36f + perun.network/perun-demo-tui v0.0.0-20240621081521-af8d85af0f76 polycry.pt/poly-go v0.0.0-20220301085937-fb9d71b45a37 ) @@ -29,7 +28,8 @@ require ( github.com/gdamore/tcell/v2 v2.6.0 // indirect github.com/go-ole/go-ole v1.3.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/protobuf v1.5.3 // indirect + github.com/golang/protobuf v1.5.4 // indirect + github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect github.com/google/gopacket v1.1.17 // indirect github.com/google/uuid v1.6.0 // indirect github.com/gorilla/websocket v1.5.1 // indirect @@ -93,6 +93,7 @@ require ( github.com/multiformats/go-multistream v0.2.0 // indirect github.com/multiformats/go-varint v0.0.6 // indirect github.com/opentracing/opentracing-go v1.2.0 // indirect + github.com/perun-network/perun-libp2p-wire v0.1.1 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rivo/tview v0.0.0-20230621164836-6cc0565babaf // indirect @@ -103,6 +104,7 @@ require ( github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/stretchr/objx v0.5.2 // indirect + github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect github.com/tklauser/go-sysconf v0.3.13 // indirect github.com/tklauser/numcpus v0.7.0 // indirect github.com/whyrusleeping/multiaddr-filter v0.0.0-20160516205228-e903e4adabd7 // indirect @@ -121,10 +123,10 @@ require ( golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.17.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b // indirect - google.golang.org/protobuf v1.31.0 // indirect + google.golang.org/protobuf v1.33.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) replace github.com/nervosnetwork/ckb-sdk-go/v2 v2.2.0 => github.com/perun-network/ckb-sdk-go/v2 v2.2.1-0.20240618093616-6d9d92aa863d -replace perun.network/channel-service v0.0.0 => github.com/perun-network/channel-service v0.0.0-20240619092514-d1880c8fac75 +replace perun.network/channel-service v0.0.0 => github.com/perun-network/channel-service v0.0.0-20240627093723-15f145c6c285 diff --git a/go.sum b/go.sum index a013ccb..05ffc7a 100644 --- a/go.sum +++ b/go.sum @@ -68,6 +68,7 @@ github.com/ethereum/go-ethereum v1.13.10/go.mod h1:sc48XYQxCzH3fG9BcrXCOOgQk2JfZ github.com/flynn/noise v0.0.0-20180327030543-2492fe189ae6 h1:u/UEqS66A5ckRmS4yNpjmVH56sVtS/RfclBAYocb4as= github.com/flynn/noise v0.0.0-20180327030543-2492fe189ae6/go.mod h1:1i71OnUq3iUe1ma7Lr6yG6/rjvM3emb6yoL7xLFzcVQ= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko= github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg= @@ -96,15 +97,17 @@ github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:x github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= +github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/gopacket v1.1.17 h1:rMrlX2ZY2UbvT+sdz3+6J+pp2z+msCq9MxTU6ymxbBY= github.com/google/gopacket v1.1.17/go.mod h1:UdDNZ1OO62aGYVnPhxT1U6aI7ukYtA/kB8vaU0diBUM= @@ -464,24 +467,26 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg= -github.com/onsi/ginkgo v1.12.1 h1:mFwc4LvZ0xpSvDZ3E+k8Yte0hLOMxXUlP+yXtJqkYfQ= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.14.0 h1:2mOpI4JVVPBN+WQRa0WKH2eXR+Ey+uK4n7Zj0aYpIQA= +github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= -github.com/onsi/gomega v1.9.0 h1:R1uwffexN6Pr340GtYRIdZmAiN4J+iw6WG4wog1DUXg= github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA= +github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= +github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/perun-network/channel-service v0.0.0-20240619092514-d1880c8fac75 h1:mUyVGniP0X6nYnxHfQG2anXeqM1KZ+QM61HJVbBCfn8= -github.com/perun-network/channel-service v0.0.0-20240619092514-d1880c8fac75/go.mod h1:k/v5S6qMbKgmQ4I7oatS9MpL72pT9d9NKZP3XoBic8I= +github.com/perun-network/channel-service v0.0.0-20240627093723-15f145c6c285 h1:W+AyHfr7vYkkdw1YziskV2W1lIAX9K9WFATTRMlU+aM= +github.com/perun-network/channel-service v0.0.0-20240627093723-15f145c6c285/go.mod h1:JD7pe4Re/XBo3qrJrmX4rX92fQ/D7vy4oGaWG/rfbk4= github.com/perun-network/ckb-sdk-go/v2 v2.2.1-0.20240618093616-6d9d92aa863d h1:bKEECKN7hTIBn7+xTcTf0Z5TexlpktVcIsiRw2OpH8Y= github.com/perun-network/ckb-sdk-go/v2 v2.2.1-0.20240618093616-6d9d92aa863d/go.mod h1:nPpBML8fuaM1NgkKCwv2gSHiCv+xKH43fu8LA9LOQUg= -github.com/perun-network/perun-libp2p-wire v0.0.0-20240604094050-faeb97e75f3c h1:e2+S5ikuEVTVSvMhVW0Y6qPalFxi6n8DdlbsI6K4cGA= -github.com/perun-network/perun-libp2p-wire v0.0.0-20240604094050-faeb97e75f3c/go.mod h1:kA/iWKN+2BvzxuUllMmd1IY6H2oKUZ18U+60hrY19EM= +github.com/perun-network/perun-libp2p-wire v0.1.1 h1:4alLNHGMwmct/tOMSdpMoi3Do7tFE6t9zHwkJR6PXis= +github.com/perun-network/perun-libp2p-wire v0.1.1/go.mod h1:kA/iWKN+2BvzxuUllMmd1IY6H2oKUZ18U+60hrY19EM= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -531,6 +536,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4= github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ= +github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= +github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= github.com/tklauser/go-sysconf v0.3.13 h1:GBUpcahXSpR2xN01jhkNAbTLRk2Yzgggk8IM08lq3r4= github.com/tklauser/go-sysconf v0.3.13/go.mod h1:zwleP4Q4OehZHGn4CYZDipCgg9usW5IJePewFCGVEa0= github.com/tklauser/numcpus v0.7.0 h1:yjuerZP127QG9m5Zh/mSO4wqurYil27tHrqwRoRjpr4= @@ -614,6 +621,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= @@ -647,9 +656,13 @@ golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -719,10 +732,8 @@ google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQ google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -736,6 +747,7 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= @@ -748,8 +760,8 @@ perun.network/go-perun v0.11.0 h1:25aL0MsyXQ2rHziOnMwJMe70K6NTCbopZMwX67qxt/k= perun.network/go-perun v0.11.0/go.mod h1:pY/1pJ2OMlCQgEbnfGh9wVfRMJtqN0iAKsiJBLH0/Gc= perun.network/perun-ckb-backend v0.0.0-20240514141411-35bdf3afa166 h1:Y/3rPrDpspxiMDkh43sV7lkmbSDTM+m37e66kDEidR0= perun.network/perun-ckb-backend v0.0.0-20240514141411-35bdf3afa166/go.mod h1:Ebp1GCFpmlSlxuP+fSO9yk/qAllF+6GhRCe7b2533zs= -perun.network/perun-demo-tui v0.0.0-20240612133942-48e004fee36f h1:Q1wiNalum4KoZpkwZfIFC+Crf5O4yUKNgM0o3sE6/NY= -perun.network/perun-demo-tui v0.0.0-20240612133942-48e004fee36f/go.mod h1:/ysNhYj1sZbvodEUdMSowl7DFnISNgPcjo5XJn7f95s= +perun.network/perun-demo-tui v0.0.0-20240621081521-af8d85af0f76 h1:E3o+PGzeHOqH+8XYq/ct7O/ah/ek4qFy2wwhNbmBi2s= +perun.network/perun-demo-tui v0.0.0-20240621081521-af8d85af0f76/go.mod h1:/ysNhYj1sZbvodEUdMSowl7DFnISNgPcjo5XJn7f95s= polycry.pt/poly-go v0.0.0-20220301085937-fb9d71b45a37 h1:iA5GzEa/hHfVlQpimEjPV09NATwHXxSjWNB0VVodtew= polycry.pt/poly-go v0.0.0-20220301085937-fb9d71b45a37/go.mod h1:XUBrNtqgEhN3EEOP/5gh7IBd3xVHKidCjXDZfl9+kMU= rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU= diff --git a/wallet_service/wallet_service_server.go b/wallet_service/wallet_service_server.go index 2394bcb..2404fd4 100644 --- a/wallet_service/wallet_service_server.go +++ b/wallet_service/wallet_service_server.go @@ -26,7 +26,7 @@ import ( ) const ( - logFile = "wallet_service_%s.log" + logFile = "wallet_service/wallet_service_%s.log" ) // MyWalletService implements the wallet API. @@ -96,7 +96,7 @@ func NewWalletServiceServer(name string, acc *wallet.Account, privKey *secp256k1 func (ws *MyWalletService) Shutdown(wg *sync.WaitGroup) { defer wg.Done() // Decrease the wait group counter ws.logger.Println("Shutting down wallet service...") - ws.server.GracefulStop() + ws.server.Stop() ws.logger.Println("Wallet service stopped gracefully") }