Skip to content

Instantly share code, notes, and snippets.

@stefanolande
Last active November 7, 2019 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefanolande/e703afbd6e14befb6346e523a7f62065 to your computer and use it in GitHub Desktop.
Save stefanolande/e703afbd6e14befb6346e523a7f62065 to your computer and use it in GitHub Desktop.
#lang bitml
;participants public keys
(participant "Alice" "0339bd7fade9167e09681d68c5fc80b72166fe55bbb84211fd12bde1d57247fbe1")
(participant "Bob" "034a7192e922118173906555a39f28fa1e0b65657fc7f403094da4f85701a5f809")
(debug-mode)
(contract
;preconditions required to stipulate the contract
(pre
;declaration of the funding transaction output.
;"bytes" should be the serialized tx, outindex the output index (0,1,...)
(deposit "Bob" 1 "tx:bytes@outindex")
;declaration of the hash of Alice's secret, identified by a
(secret "Alice" a "9f3df038eeadc0c240fb7f82e31fdfe46804fc7c"))
;code of the contract
(choice
(reveal (a) (withdraw "Alice"))
(after 1550000 (withdraw "Bob")))
)
#|
//Compiled transactions
const pubkeyBob1 = pubkey:034a7192e922118173906555a39f28fa1e0b65657fc7f403094da4f85701a5f809
const pubkeyAlice2 = pubkey:0339bd7fade9167e09681d68c5fc80b72166fe55bbb84211fd12bde1d57247fbe1
const pubkeyAlice4 = pubkey:0339bd7fade9167e09681d68c5fc80b72166fe55bbb84211fd12bde1d57247fbe1
const pubkeyBob5 = pubkey:034a7192e922118173906555a39f28fa1e0b65657fc7f403094da4f85701a5f809
const pubkeyBob3 = pubkey:034a7192e922118173906555a39f28fa1e0b65657fc7f403094da4f85701a5f809
const pubkeyAlice6 = pubkey:0339bd7fade9167e09681d68c5fc80b72166fe55bbb84211fd12bde1d57247fbe1
const sec_a = _ //add value of secret a
const pubkeyBob = pubkey:034a7192e922118173906555a39f28fa1e0b65657fc7f403094da4f85701a5f809
const pubkeyAlice = pubkey:0339bd7fade9167e09681d68c5fc80b72166fe55bbb84211fd12bde1d57247fbe1
const sigBob0 : signature = _ //add signature for output tx:bytes@outindex
transaction Tinit {
input = [ tx:bytes@outindex:sigBob0; ]
output = 1 BTC : fun(a:string, sBob, sAlice) . (( (hash160(a) == hash:9f3df038eeadc0c240fb7f82e31fdfe46804fc7c && size(a) >= 128 && versig(pubkeyBob1, pubkeyAlice2; sBob, sAlice)) ||
versig(pubkeyBob3, pubkeyAlice4; sBob, sAlice) ))
}
const sigBobT1 : signature = _
const sigAliceT1 : signature = _
transaction T1 {
input = [ Tinit@0:sec_a sigBobT1 sigAliceT1 ]
output = 1 BTC : fun(sBob, sAlice) . versig(pubkeyBob5, pubkeyAlice6; sBob, sAlice)
}
const sigBobT2 : signature = _
const sigAliceT2 : signature = _
transaction T2 {
input = [ T1@0: sigBobT2 sigAliceT2 ]
output = 1 BTC : fun(x) . versig(pubkeyAlice; x)
}
const sigBobT3 : signature = _
const sigAliceT3 : signature = _
transaction T3 {
input = [ Tinit@0: "0" sigBobT3 sigAliceT3 ]
output = 1 BTC : fun(x) . versig(pubkeyBob; x)
absLock = block 1550000
}
|#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment