Payment Channel

Introduction
2017/10/03 blockchain.tokyo #1
@mosa_siru
@mosa_siru ( )
•
• TV
• Gunosy
PO
@mosa_siru as engineer
•
• (DeNA)
• (Gunosy)
• (Gunosy)
1. Payment channel
2. HTLCs
bitcoin micro payment
•
• (API )
• bitcoin 1 1
• 2017/10 150
• ( ) 10
• 3.47
• platform


user
• platform user
• platform BTC 

user 10 

platform BTC
• user platform
•
• platform
Payment channel
• trustless ( )
• off-chain transaction(
broadcast )
• off-chain
Multisig
• 

( ) of ( )
• 2 of 3 ( 3 2
• 1 of 2 ( )
• 2 of 2 ( )
P2SH Redeem script: OP_2 [A's pubkey] [B's pubkey] OP_2 OP_CHECKMULTISIG
CLTV(CheckLockTimeVerify)
• BIP65 (Final) (OP_CHECKLOCKTIMEVERIFY)
• unspentable


( BTC )
※ nLockTime
( UTXO )
CSV(CheckSequenceVerify)
• BIP112 (Final) (OP_CHECKSEQUENCEVERIFY)
• (
) unspentable 

BTC (3 )
•
• CLTV CSV TimeLock
Payment Channel
Payment Channel
• trustless(A, B )
• trustless 2 of 2 multisig(A, B
)
• fund
• off-chain
(100 )
Payment Channel (1)
A → B micro payment
1. A 2 of 2(multisig) fund 1BTC deposite
broadcast
2. 1 txid 1 1BTC A
refund transaction 

B CSV CLTV
3. 1 broadcast (channel open
Payment Channel (2)
4. deposite address A, B
A B
(off-chain)


deposite address => B(0.01BTC), A(0.99BTC) 

deposite address => B(0.02BTC), A(0.98BTC)

…
5. B broadcast
(channel close)
Bob => Alice
https://bitcoin.org/en/developer-guide#micropayment-channel
Trustless (1)
• B
• refund transaction( ) broadcast 1 (CSV
or CLTV) A
• refund transaction B B
fund deposite
• B 1 A
Trustless (2)
• A
• B broadcast
Time Lock
• refund CLTV( )
channel close (B )
CSV( )
• CLTV nLockTime(
)
• deposite txid
refund transaction 

segwit
•
• channel
• deposite
•
HTLC
HTLC

(Hashed TimeLock Contracts)
• CSV, CTLV TimeLock HashLock
• A => B => C
• channel
• B A
• Lightning Network
HTLC (1)
A => C micro payment
1. A => B , B => C payment channel
2. C A r
hash(r)
generate rOpen
channel
Open
channel
HTLC (2)
3. A => B 1BTC tx1 (off-chain)

IF
1. B r
2. 10 A (CLTV) ※refund .
4. Tx1 B => C 1BTC tx2 (off-chain)
1. C r
2. 5 B (CTLV) ← tx1
5. C r tx2 broadcast 1BTC
r B tx1 broadcast 1BTC
HTLC (1)
• trustless A => B => C
•
• tx2 tx1 refund B
CSV
CLTV tx2
HTLC (2)
• Tx1 (A => B) tx2
segwit
id
• r
pre-image
Payment Channel

(Bidirectional)
Payment Channel
(Bidirectional)
• payment channel
• channel 2
fund
• Time Lock, Hash Lock
Payment Channel
(Bidirectional)
1. A, B 5BTC 2 of 2 fund
opening transaction (off-chain)
2. A secret1, B secret2( )
hash
Payment Channel
(Bidirectional)
3. A commitment transaction tx2 B (off-chain)
4. B commitment transaction tx1 A (off-chain)
100block secret 

opening transaction broadcast.
Payment Channel
(Bidirectional)
A => B 1BTC
5. tx3, tx4 secret
6. Secret 1, 2 hash tx1, tx2
transaction
• A => B 1BTC A tx1, tx2
secret
• A tx1 broadcast A 5BTC
100block B 5BTC
secret1 10BTC
Payment Channel
(Bidirectional)
7. transaction broadcast
•
layer2
• CTLV, CSV
•
trustless
• …
@mosa_siru

Payment Channel Introduction