0g-chain/docs/paychans.md

40 lines
1.6 KiB
Markdown
Raw Normal View History

2018-09-18 23:14:46 +00:00
# Payment Channels
2018-07-08 22:09:07 +00:00
2018-09-18 23:14:46 +00:00
Payment channels are designed to enable high speed and throughput for transactions while requiring no counter-party risk.
This initial implementation is for unidirectional 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).
2018-07-08 22:09:07 +00:00
2018-09-02 02:57:42 +00:00
# Usage
2018-09-18 23:14:46 +00:00
>The following commands require communication with a full node. By default they expect one to be running locally (accessible on localhost), but a remote can be provided with the `--node` flag.
2018-09-02 02:57:42 +00:00
## Create a channel
2018-09-20 20:10:37 +00:00
kvcli paychan create --from <your account name> --to <receivers address> --amount 100KVA
2018-09-02 02:57:42 +00:00
## Send an off-chain payment
Send a payment for 10 KVA.
2018-09-20 20:10:37 +00:00
kvcli paychan pay --from <your account name> --sen-amt 90KVA --rec-amt 10KVA --chan-id <ID of channel> --filename payment.json
2018-09-02 02:57:42 +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.
2018-09-20 20:10:37 +00:00
kvcli paychan submit --from <receiver's account name> --payment payment.json
2018-09-02 02:57:42 +00:00
2018-09-18 23:14:46 +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, overruling the sender's request.
2018-09-02 02:57:42 +00:00
2018-09-20 20:10:37 +00:00
kvcli paychan submit --from <receiver's account name> --payment payment.json
2018-09-02 02:57:42 +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>
This will print out a channel, if it exists, and any submitted close requests.