Transactions in LN are off-chain, so transactions couldn't be stored in main-chain, so how could you look-up the transactions history?
You cannot view the transaction history of any node except your own. Transactions in LN are private and sent encrypted over an onion routing layer. It is up to the software client to keep track of payments if you want your own payment history.
Payment channel is private for someone outside, and if there is no transaction history, how do i give the information to others to proof that I've just made a payment in LN.
Every payment on LN uses a 256-bit random number, called a payment_preimage
. The preimage is hashed using SHA256 to produce a payment_hash
. The intended recipient of funds initally witholds the payment_preimage
, but gives you the payment_hash
and asks you to make the payment.
When you make the payment, it is made for a specific payment_hash
. This is done with a Hashed Time-Locked Contract (HTLC), which is a conditional payment. The payment expires after a timeout, unless the intended recipient accepts the payment by surrendering the payment_preimage
for that payment_hash
. If the recipient does not accept the payment, they must fail the HTLC before the timeout, else their channel may be forcibly closed and they will not receive the payment.
Once the recipient has accepted a payment by sending the payment_preimage
, it is trivial for you to prove that you have paid payment_hash
, because anybody can perform the SHA256 on the preimage and assert that it matches payment_hash
. The assumption here is that SHA256 is cryptographically secure and it is not possible to brute force a payment_preimage
to produce an expected payment_hash
.
By surrendering the payment_preimage
to accept the payment, the recipient has provided proof that you have paid.
Note that this must assume that a preimage is never reused. Every payment must use a unique random preimage else it may be possible that funds are stolen.