Hash Time-Locked Contracts


In connection with the Lightning network thread it would be nice to implement HTLC at the network level.


There is no significant barriers for HTLC and Lightning network.

sha256 (plus keccak and blake2b) already available at the network level: https://docs.wavesplatform.com/en/technical-details/waves-contracts-language-description/standard-library.html


Thanks, I know it.
So, every time the channel updates we will need to create two new contracts (broadcasted)?
Am I misunderstanding something?


I can create something like this:

let alicePK = base58'2vet7Phh3JLvc5xRknLoT6YbBsnyU98LywPsER6ixStk'
let bobPK = base58'2vet7Phh3JLvc5xRknLoT6YbBsnyU98LywPsER6ixStk'
match tx {
  case a:TransferTransaction =>
    let bobProof = sigVerify(tx.bodyBytes, tx.proofs[0], bobPK)
    let bobHash = sha256(a.attachment) == base58'hashofsecret'
    let aliceProof = sigVerify(tx.bodyBytes, tx.proofs[0], alicePK)
    let aliceTime = a.timestamp > 1542166543728
    let multisig = aliceProof && sigVerify(tx.bodyBytes, tx.proofs[1], bobPK)
    (bobProof && bobHash) || (aliceProof && aliceTime) || multisig
  case _ => false

But I can’t use it without broadcasting imho. All the charms of the channels are lost.


Why not? Channel locks money publicly, what’s wrong?