Update send-a-conditionally-held-escrow.md

Added python example for generating escrow condition and fulfillment
This commit is contained in:
Obiajulu
2022-05-05 11:31:54 -07:00
committed by GitHub
parent b041b31057
commit 71880b2ea8

View File

@@ -35,6 +35,20 @@ console.log('Fulfillment:', fulfillment)
// (Random hexadecimal, 78 chars in length)
```
Example Python code for a random fulfillment and condition:
``` py
from cryptoconditions import PreimageSha256
secret = b"Python is awesome" # modify this if you want to change the output
# scret must be bytes format
fufill = PreimageSha256(preimage=secret)
print("Condition", str.upper(fufill.condition_binary.hex()))
print("Fulfillment", str.upper(fufill.serialize_binary().hex()))
```
Save the condition and the fulfillment for later. Be sure to keep the fulfillment secret until you want to finish executing the held payment. Anyone who knows the fulfillment can finish the escrow, releasing the held funds to their intended destination.