0g-chain/internal/x/paychan/README.md

55 lines
2.3 KiB
Markdown
Raw Normal View History

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-02 02:57:42 +00:00
>Note: This is a work in progress. 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>
Send the file payment.json to your receiver. Then they run the following to verify.
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>
The sender can close subject to a dispute period during which the receiver can overrule them.
kvcli paychan submit --from <receiver's account name> --payment payment.json --chain-id <your chain ID>
## Get info on a channel
kvcli get --chan-id <ID of channel>
# 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
- 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 doesnt throw json parsing error on invalid json
- cant 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
- 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