Arbitrary channel capacities
In the previous post we discussed about splitting our deposits to a bunch of channels based on a predefined strategy. A big problem with this approach is that not all of our transactions may fit well with our channel set. What if our smallest channel is 1ETH and we want to pay someone 0.01ETH? (Or vice versa) Then initializing a 1ETH channel for such a small payment would be really wasteful (Unless we are completely sure that we are going to send more funds to that user in the future)
A better approach would be to let the user choose an appropriate capacity for his newly initialized channel.
In order to make this viable, we have to change the previous proposal a little bit.
- On each deposit, instead of creating a bunch of Channel objects (Where each leaf of our Sparse-Merkle-Tree was representing a channel), a single Deposit object is created. (And each leaf of the Sparse-Merkle-Tree represents a Deposit)
- The operator puts root of a Merkle-Sum-Tree in each leaf of the Sparse-Merkle-Tree (Where summation of all leaves of this Merkle-Sum-Tree should be equal with the value of the corresponding Deposit object) (You can find a great explanation on Merkle-Sum-Trees here)
- We place initialization messages of our channels inside the leaves of the Merkle-Sum-Tree.
- Capacity of the initialized channel should be equal with the range length of the corresponding leaf of the Merkle-Sum-Tree.
- Ranges of the initialized channels should not overlap with each other.
An initialization message of a channel with capacity C in range (s, s+C) in k th Deposit object in block N is considered valid if:
- It has been signed by the creator of the k th Deposit object.
- All k th leaves of blocks 0 \leq i \leq N-1 have Merkle-Sum-Roots that are either null in range (s,s+C), or have invalid content (Not signed by the corresponding Deposit creator)
Now users can create arbitrary number of payment-channels, with arbitrary capacities, off-chain.