2018-09-02 02:57:42 +00:00
# Unidrectional Payment Channels
2018-07-08 22:09:07 +00:00
2018-09-02 02:57:42 +00:00
This module implements simple but feature complete unidirectional payment channels. Channels can be opened by a sender and closed immediately by the receiver, or by the sender subject to a dispute period. There are no top-ups or partial withdrawals (yet). Channels support multiple currencies.
2018-07-08 22:09:07 +00:00
2018-09-03 20:38:51 +00:00
>Note: This module is still a bit rough around the edges. More feature planned. More test cases needed.
2018-07-08 22:09:07 +00:00
2018-09-02 02:57:42 +00:00
# Usage
## Create a channel
kvcli paychan create --from < your account name > --to < receivers address > --amount 100KVA --chain-id < your chain ID >
## Send an off-chain payment
Send a payment for 10 KVA.
kvcli paychan pay --from < your account name > --sen-amt 90KVA --rec-amt 10KVA --chan-id < ID of channel > --filename payment.json --chain-id < your chain ID >
2018-09-03 20:38:51 +00:00
Send the file `payment.json` to your receiver. Then they run the following to verify.
2018-09-02 02:57:42 +00:00
kvcli paychan verify --filename payment.json
## Close a channel
The receiver can close immediately at any time.
kvcli paychan submit --from < receiver ' s account name > --payment payment.json --chain-id < your chain ID >
2018-09-03 20:38:51 +00:00
The sender can submit a close request, causing the channel will close automatically after a dispute period. During this period a receiver can still close immediately.
2018-09-02 02:57:42 +00:00
kvcli paychan submit --from < receiver ' s account name > --payment payment.json --chain-id < your chain ID >
2018-09-03 20:38:51 +00:00
>Note: The dispute period on the testnet is 30 seconds for ease of testing.
2018-09-02 02:57:42 +00:00
## Get info on a channel
kvcli get --chan-id < ID of channel >
2018-09-03 20:38:51 +00:00
This will print out a channel, if it exists, and any submitted close requests.
2018-09-02 02:57:42 +00:00
# TODOs
2018-07-08 22:09:07 +00:00
2018-09-01 18:37:10 +00:00
- in code TODOs
- Tidy up - method descriptions, heading comments, remove uneccessary comments, README/docs
2018-08-27 21:58:58 +00:00
- Find a better name for Queue - clarify distinction between int slice and abstract queue concept
2018-09-01 18:37:10 +00:00
- write some sort of integration test
2018-09-02 02:22:50 +00:00
- possible bug in submitting same update repeatedly
2018-09-01 17:16:56 +00:00
- find nicer name for payout
2018-09-01 18:37:10 +00:00
- add Gas usage
- add tags (return channel id on creation)
2018-09-01 20:41:40 +00:00
- refactor cmds to be able to test them, then test them
2018-09-02 02:22:50 +00:00
- verify doesn’ t throw json parsing error on invalid json
- can’ t submit an update from an unitialised account
- pay without a --from returns confusing error
2018-09-01 18:37:10 +00:00
- use custom errors instead of using sdk.ErrInternal
- split off signatures from update as with txs/msgs - testing easier, code easier to use, doesn't store sigs unecessarily on chain
2018-09-01 17:16:56 +00:00
- consider removing pubKey from UpdateSignature - instead let channel module access accountMapper
2018-09-01 18:37:10 +00:00
- refactor queue into one object
2018-09-02 02:57:42 +00:00
- remove printout during tests caused by mock app initialisation