Hash Time Lock Contract (HTLC)¶
Bytom Hash Time Lock Contract (HTLC).
-
class
shuttle.providers.bytom.htlc.
HTLC
(network='testnet')¶ Bytom Hash Time Lock Contract (HTLC) class.
- Parameters
network (str) – bytom network, defaults to testnet.
- Returns
HTLC – bytom HTLC instance.
Note
Bytom has only three networks,
mainnet
,solonet
andtestnet
.-
bytecode
()¶ Get bytom htlc bytecode.
- Returns
str – bytom Hash Time Lock Contract (HTLC) bytecode.
>>> from shuttle.providers.bytom.htlc import HTLC >>> htlc = HTLC(network="testnet") >>> htlc.init(secret_hash, recipient_public_key, sender_public_key, 100) >>> htlc.bytecode() "01642091ff7f525ff40874c4f47f0cab42e46e3bf53adad59adef9558ad1b6448f22e220ac13c0bb1445423a641754182d53f0677cd4351a0e743e6f10b35122c3d7ea01202b9a5949f5546f63a253e41cda6bffdedb527288a7e24ed953f5c2680c70d6ff741f547a6416000000557aa888537a7cae7cac631f000000537acd9f6972ae7cac00c0"
-
init
(secret_hash, recipient_public, sender_public, sequence=100)¶ Initialize bytom Hash Time Lock Contract (HTLC).
- Parameters
secret_hash (str) – secret sha-256 hash.
recipient_public (str) – bytom recipient public key.
sender_public (str) – bytom sender public key.
sequence (int) – bytom sequence number of expiration block, defaults to bytom config sequence (15).
- Returns
HTLC – bytom Hash Time Lock Contract (HTLC) instance.
>>> from shuttle.providers.bytom.htlc import HTLC >>> htlc = HTLC(network="testnet") >>> htlc.init(secret_hash, recipient_public_key, sender_public_key, 100) <shuttle.providers.bytom.htlc.HTLC object at 0x0409DAF0>
-
opcode
()¶ Get bytom htlc opcode.
- Returns
str – bytom Hash Time Lock Contract (HTLC) opcode.
>>> from shuttle.providers.bytom.htlc import HTLC >>> htlc = HTLC(network="testnet") >>> htlc.init(secret_hash, recipient_public_key, sender_public_key, 100) >>> htlc.opcode() "0x64 0x91ff7f525ff40874c4f47f0cab42e46e3bf53adad59adef9558ad1b6448f22e2 0xac13c0bb1445423a641754182d53f0677cd4351a0e743e6f10b35122c3d7ea01 0x2b9a5949f5546f63a253e41cda6bffdedb527288a7e24ed953f5c2680c70d6ff DEPTH 0x547a6416000000557aa888537a7cae7cac631f000000537acd9f6972ae7cac FALSE CHECKPREDICATE"