def test_bytom_htlc(): htlc = HTLC(network="mainnet").init( secret_hash=sha256("Hello Meheret!".encode()).hex(), recipient_public= "91ff7f525ff40874c4f47f0cab42e46e3bf53adad59adef9558ad1b6448f22e2", sender_public= "3e0a377ae4afa031d4551599d9bb7d5b27f4736d77f78cac4d476f0ffba5ae3e", sequence=1000, use_script=False) assert htlc.bytecode() == "02e803203e0a377ae4afa031d4551599d9bb7d5b27f4736d77f78cac4d476f0ffba5ae3e2091ff" \ "7f525ff40874c4f47f0cab42e46e3bf53adad59adef9558ad1b6448f22e2203a26da82ead15a80" \ "533a02696656b14b5dbfd84eb14790f2e1be5e9e45820eeb741f547a6416000000557aa888537a" \ "7cae7cac631f000000537acd9f6972ae7cac00c0" assert htlc.opcode() == "0xe803 0x3e0a377ae4afa031d4551599d9bb7d5b27f4736d77f78cac4d476f0ffba5ae3e 0x91ff" \ "7f525ff40874c4f47f0cab42e46e3bf53adad59adef9558ad1b6448f22e2 0x3a26da82ead15a805" \ "33a02696656b14b5dbfd84eb14790f2e1be5e9e45820eeb DEPTH 0x547a6416000000557aa88853" \ "7a7cae7cac631f000000537acd9f6972ae7cac FALSE CHECKPREDICATE" assert htlc.hash( ) == "a5addb7eb5649d10031304ece72d9ccc9dc424abcda895d904a309727424e40e" assert htlc.address( ) == "bm1q5kkakl44vjw3qqcnqnkwwtvuejwugf9tek5ftkgy5vyhyapyus8qgcttcs" assert HTLC().from_bytecode(bytecode=htlc.bytecode())
recipient_address = recipient_bytom_wallet.address() print("Recipient Address:", recipient_address) # recipient_balance = recipient_bytom_wallet.balance() # print("Recipient Balance:", recipient_balance) print("=" * 10, "Hash Time Lock Contract (HTLC) between Sender and Recipient") # Initialization Hash Time Lock Contract (HTLC). bytom_htlc = HTLC(network="mainnet").init( secret_hash=sha256("Hello Meheret!".encode()).hex(), recipient_public=recipient_public_key, sender_public=sender_public_key, sequence=100 ) htlc_bytecode = bytom_htlc.bytecode() print("HTLC Bytecode:", htlc_bytecode) htlc_opcode = bytom_htlc.opcode() print("HTLC OP_Code:", htlc_opcode) print("=" * 10, "Unsigned Fund Transaction") # Initialization fund transaction unsigned_fund_transaction = FundTransaction(network="mainnet") # Building fund transaction unsigned_fund_transaction.build_transaction( wallet=sender_bytom_wallet, htlc=bytom_htlc, amount=100, asset="f37dea62efd2965174b84bbb59a0bd0a671cf5fb2857303ffd77c1b482b84bdf" )
print("Recipient Program:", recipient_program) recipient_address = recipient_wallet.address() print("Recipient Address:", recipient_address) # recipient_balance = recipient_wallet.balance() # print("Recipient Balance:", recipient_balance) print("=" * 10, "Hash Time Lock Contract (HTLC) between Sender and Recipient") # Initializing Hash Time Lock Contract (HTLC) htlc = HTLC(network=NETWORK).init(secret_hash=sha256( "Hello Meheret!".encode()).hex(), recipient_public=recipient_public_key, sender_public=sender_public_key, sequence=1000) htlc_bytecode = htlc.bytecode() print("HTLC Bytecode:", htlc_bytecode) htlc_opcode = htlc.opcode() print("HTLC OP_Code:", htlc_opcode) htlc_hash = htlc.hash() print("HTLC Hash:", htlc_hash) htlc_address = htlc.address() print("HTLC Address:", htlc_address) print("=" * 10, "Unsigned Fund Transaction") # Initializing fund transaction unsigned_fund_transaction = FundTransaction(network=NETWORK) # Building fund transaction unsigned_fund_transaction.build_transaction(wallet=sender_wallet, htlc=htlc,