mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-12-06 17:27:57 +00:00
Remove some old Escrow tutorials and rewrite conditional escrow tutorial in new format
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
import random
|
||||
from os import urandom
|
||||
|
||||
from cryptoconditions import PreimageSha256
|
||||
|
||||
# """Generate a condition and fulfillment for escrows"""
|
||||
|
||||
# Generate a random preimage with at least 32 bytes of cryptographically-secure randomness.
|
||||
secret = urandom(32)
|
||||
|
||||
# Generate cryptic image from secret
|
||||
fufill = PreimageSha256(preimage=secret)
|
||||
|
||||
# Parse image and return the condition and fulfillment
|
||||
condition = str.upper(fufill.condition_binary.hex()) # conditon
|
||||
fulfillment = str.upper(fufill.serialize_binary().hex()) # fulfillment
|
||||
|
||||
# Print condition and fulfillment
|
||||
print(f"condition: {condition} \n fulfillment {fulfillment}")
|
||||
@@ -1,5 +1,5 @@
|
||||
import json
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import datetime, timedelta, UTC
|
||||
from os import urandom
|
||||
|
||||
from cryptoconditions import PreimageSha256
|
||||
@@ -28,7 +28,7 @@ print("Fulfillment:", fulfillment_hex)
|
||||
|
||||
# Set the escrow expiration -------------------------------------------------
|
||||
cancel_delay = 300
|
||||
cancel_after = datetime.now() + timedelta(seconds=cancel_delay)
|
||||
cancel_after = datetime.now(tz=UTC) + timedelta(seconds=cancel_delay)
|
||||
print("This escrow will expire after", cancel_after)
|
||||
cancel_after_rippletime = datetime_to_ripple_time(cancel_after)
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import json
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import datetime, timedelta, UTC
|
||||
from time import sleep
|
||||
from os import urandom
|
||||
|
||||
from xrpl.clients import JsonRpcClient
|
||||
from xrpl.models import EscrowCreate, EscrowFinish
|
||||
@@ -21,8 +20,8 @@ destination_address = generate_faucet_wallet(client, debug=True).address
|
||||
|
||||
# Set the escrow finish time ------------------------------------------------
|
||||
delay = 30
|
||||
finish_after = datetime.now() + timedelta(seconds=delay)
|
||||
print("This escrow will expire after", finish_after)
|
||||
finish_after = datetime.now(tz=UTC) + timedelta(seconds=delay)
|
||||
print("This escrow will mature after", finish_after)
|
||||
finish_after_rippletime = datetime_to_ripple_time(finish_after)
|
||||
|
||||
# Send EscrowCreate transaction ---------------------------------------------
|
||||
@@ -45,6 +44,7 @@ if result_code != "tesSUCCESS":
|
||||
|
||||
# Save the sequence number so you can identify the escrow later
|
||||
escrow_seq = response.result["tx_json"]["Sequence"]
|
||||
print(f"Escrow sequence is {escrow_seq}.")
|
||||
|
||||
# Wait for the escrow to be finishable --------------------------------------
|
||||
sleep(delay)
|
||||
@@ -68,7 +68,7 @@ while not escrow_ready:
|
||||
sleep(time_difference)
|
||||
|
||||
|
||||
# Send the EscrowFinish transaction -----------------------------------------
|
||||
# Send EscrowFinish transaction ---------------------------------------------
|
||||
escrow_finish = EscrowFinish(
|
||||
account=wallet.address,
|
||||
owner=wallet.address,
|
||||
|
||||
Reference in New Issue
Block a user