コード例 #1
0
ファイル: withdraw.py プロジェクト: movnetwork/swap
XRC20: bool = True
# XinFin HTLC XRC20 contract address
CONTRACT_ADDRESS: str = "xdc4C909fdd6c30f5B4c4d48938C161637B2767d714"
# XinFin HTLC XRC20 funded transaction hash/id
TRANSACTION_HASH: str = "0xfc28ef53d380d98bee785060c0ceaf382078b48af4e94a61aa0997ebcb1ed57b"
# XinFin recipient wallet mnemonic
RECIPIENT_MNEMONIC: str = "hint excuse upgrade sleep easily deputy erase cluster section other ugly limit"
# XinFin XRC20 token address
TOKEN_ADDRESS: str = "xdcd66dA17A97a91445A2B89805e9fa4B0ff649BF49"
# The preimage of HTLC XRC20 contract
SECRET_KEY: str = "Hello Meheret!"

print("=" * 10, "Recipient XinFin Account")

# Initialize XinFin recipient wallet
recipient_wallet: Wallet = Wallet(network=NETWORK)
# Get XinFin recipient wallet from mnemonic
recipient_wallet.from_mnemonic(mnemonic=RECIPIENT_MNEMONIC)
# Drive XinFin recipient wallet from path
recipient_wallet.from_path(path=DEFAULT_PATH)

# Print some XinFin recipient wallet info's
print("Root XPrivate Key:", recipient_wallet.root_xprivate_key())
print("Root XPublic Key:", recipient_wallet.root_xpublic_key())
print("Private Key:", recipient_wallet.private_key())
print("Public Key:", recipient_wallet.public_key())
print("Path:", recipient_wallet.path())
print("Address:", recipient_wallet.address())
print("Balance:", recipient_wallet.balance(unit="XDC"), "XDC")
print("XRC20 Balance:",
      recipient_wallet.xrc20_balance(token_address=TOKEN_ADDRESS))
コード例 #2
0
ファイル: fund.py プロジェクト: saloppe73/swap
CONTRACT_ADDRESS: str = "xdc656869af3Ec1E8b2982Fc370A0526541C0Ceb90B"
# Secret key hash
SECRET_HASH: str = sha256("Hello Meheret!")
# XinFin sender wallet mnemonic
SENDER_MNEMONIC: str = "unfair divorce remind addict add roof park clown build renew illness fault"
# XinFin recipient address
RECIPIENT_ADDRESS: str = "xdcf8D43806260CFc6cC79fB408BA1897054667F81C"
# Expiration block timestamp
ENDTIME: int = get_current_timestamp(plus=3600)  # 1 hour
# XinFin fund amount
AMOUNT: int = amount_unit_converter(1, "XDC2Wei")

print("=" * 10, "Sender XinFin Account")

# Initialize XinFin sender wallet
sender_wallet: Wallet = Wallet(network=NETWORK)
# Get XinFin sender wallet from mnemonic
sender_wallet.from_mnemonic(mnemonic=SENDER_MNEMONIC)
# Drive XinFin sender wallet from path
sender_wallet.from_path(path=DEFAULT_PATH)

# Print some XinFin sender wallet info's
print("Root XPrivate Key:", sender_wallet.root_xprivate_key())
print("Root XPublic Key:", sender_wallet.root_xpublic_key())
print("Private Key:", sender_wallet.private_key())
print("Public Key:", sender_wallet.public_key())
print("Path:", sender_wallet.path())
print("Address:", sender_wallet.address())
print("Balance:", sender_wallet.balance(unit="XDC"), "XDC")

print("=" * 10, "Build Hash Time Lock Contract (HTLC) between Sender and Recipient")
コード例 #3
0
def test_xinfin_wallet_from_seed():

    wallet = Wallet(network=_["xinfin"]["network"])

    wallet.from_seed(
        seed=_["xinfin"]["wallet"]["recipient"]["seed"]
    )

    wallet.from_path(
        path=_["xinfin"]["wallet"]["recipient"]["derivation"]["path"]
    )

    assert wallet.entropy() is None
    assert wallet.mnemonic() is None
    assert wallet.language() is None
    assert wallet.passphrase() is None
    assert wallet.seed() == _["xinfin"]["wallet"]["recipient"]["seed"]
    assert wallet.root_xprivate_key() == _["xinfin"]["wallet"]["recipient"]["root_xprivate_key"]
    assert wallet.root_xpublic_key() == _["xinfin"]["wallet"]["recipient"]["root_xpublic_key"]
    assert wallet.xprivate_key() == _["xinfin"]["wallet"]["recipient"]["xprivate_key"]
    assert wallet.xpublic_key() == _["xinfin"]["wallet"]["recipient"]["xpublic_key"]
    assert wallet.uncompressed() == _["xinfin"]["wallet"]["recipient"]["uncompressed"]
    assert wallet.compressed() == _["xinfin"]["wallet"]["recipient"]["compressed"]
    assert wallet.chain_code() == _["xinfin"]["wallet"]["recipient"]["chain_code"]
    assert wallet.private_key() == _["xinfin"]["wallet"]["recipient"]["private_key"]
    assert wallet.public_key() == _["xinfin"]["wallet"]["recipient"]["public_key"]
    assert wallet.wif() == _["xinfin"]["wallet"]["recipient"]["wif"]
    assert wallet.hash() == _["xinfin"]["wallet"]["recipient"]["hash"]
    assert wallet.finger_print() == _["xinfin"]["wallet"]["recipient"]["finger_print"]
    assert wallet.path() == _["xinfin"]["wallet"]["recipient"]["derivation"]["path"]
    assert wallet.address() == _["xinfin"]["wallet"]["recipient"]["address"]