This repository contains contains an implementation of the Channel Service, which is standardized to allow implementing Perun channels into any CKB wallet ready to conform with the standard.
The specification can be found in the repository perun-wallet-spec.
The Perun-Channel-Service is a core component designed to facilitate the integration of Perun payment channels into CKB wallets. By adhering to the standardized implementation, developers can seamlessly integrate this service into their wallet applications, ensuring compatibility and enhanced functionality.
- Perun Payment Channels interactions (Open, Update, Close, Restore)
- Built-in persistence
- Compatible with any CKB wallet
- Follows the perun-wallet-spec
- Open-source under the Apache 2.0 license
Import the Perun-Channel-Service module:
go get github.com/perun-network/channel-service
You might need to replace the github path with the actual module name in your go.mod:
require (
github.com/perun-network/perun-channel-service v0.0.0
)
replace perun.network/channel-service v0.0.0 => github.com/perun-network/channel-service v0.1.0
Start a Channel-Service instance in a GRPC Server:
// Create a channel service instance.
cs, err := service.NewChannelService(wsc, network, rpcNodeUrl, d, nil, db)
if err != nil { /* error handling */ }
// Deploy the channel service on a GRPC Server.
lis := bufconn.Listen(bufSize)
baseServer := grpc.NewServer()
proto.RegisterChannelServiceServer(baseServer, cs)
go func() {
err := baseServer.Serve(lis)
if err != nil { /* error handling */ }
}()
/*
// ...
*/
// Clean up after use.
defer func() {
err := lis.Close()
if err != nil { /* error handling */ }
baseServer.Stop()
}()Wallet User can create a Channel Service Client by connecting to the GRPC Server:
// Dial connection with channel service server.
conn, err := grpc.DialContext(context.Background(), "bufnet", grpc.WithContextDialer(func(context.Context, string) (defaultnet.Conn, error) {
return lis.Dial()
}), grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil { /* error handling */ }
// Create the channel service client.
channelServiceClient := proto.NewChannelServiceClient(conn)We use various tools to enable a convenient setup for the local development testnet. If you want to use our setup-devnet.sh script, make sure the following commandline tools are installed:
jq:- Used to parse and edit some configuration files.
sedandawk:- We modify some fields of the files generated by the
ckb init --chain devcommand usingsedandawk.
- We modify some fields of the files generated by the
tmuxandtmuxp:tmuxpis a session manager fortmuxthat allows to easily create descriptive.yamlconfiguration files to create and attach totmuxsessions.
expect:- We completely automize the process for test-wallet creation, deploying of contracts etc. To make this work reliably, we use
expectwhich allows to describe how a commandline application is fed input.
- We completely automize the process for test-wallet creation, deploying of contracts etc. To make this work reliably, we use
make:- Not strictly necessary, but it should be available on most systems by default. In case you do not want to install
makecheck out theMakefilecontent and issue the command on your own.
- Not strictly necessary, but it should be available on most systems by default. In case you do not want to install
ckbwith version0.109.0or higher.ckb-cliwith version1.4.0or higher.capsulewith version0.9.2.dockerand a runningdockerdinstance!
Start a test chain on a terminal.
cd ./test/devnet
make devTest the channel-service on another terminal.
go test -v channel_service_test.go
The Perun-Nervos-Demo demonstrates the use of how a Wallet User can interact with the Channel-Service through RPC Messages and manage Perun Payment Channels on Nervos Network.
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
