Beispiel #1
0
import json

# Choose network mainnet or testnet
NETWORK: str = "ropsten"
# Ethereum HTLC contract address
CONTRACT_ADDRESS: str = "0xE5cb615899436A490dBde26d7880A0C2502Fc676"
# Ethereum funded transaction hash/id
TRANSACTION_HASH: str = "0xa42f5c441c9ba006c6abcbdbb6e1a3f21e491a9803df127958ee5acd8e17b74e"
# Ethereum sender wallet mnemonic
SENDER_MNEMONIC: str = "unfair divorce remind addict add roof park clown build renew illness fault"

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

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

# Print some Ethereum 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="Ether"), "Ether")

print("=" * 10, "Unsigned Refund Transaction")
Beispiel #2
0
# Choose network mainnet, ropsten, kovan, rinkeby or testnet
NETWORK: str = "ropsten"
# Ethereum HTLC contract address
CONTRACT_ADDRESS: str = "0x0cc7C744f96729B7f60B12B36A4B9504191CD458"
# Ethereum HTLC funded transaction hash/id
TRANSACTION_HASH: str = "0xab72920d11012d7333e49dfe062b01e3d46c41002c0412adafd8e93eb8836577"
# Ethereum recipient wallet mnemonic
RECIPIENT_MNEMONIC: str = "hint excuse upgrade sleep easily deputy erase cluster section other ugly limit"
# The preimage of HTLC contract
SECRET_KEY: str = "Hello Meheret!"

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

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

# Print some Ethereum 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="Ether"), "Ether")

print("=" * 10, "Unsigned Withdraw Transaction")
Beispiel #3
0
def test_ethereum_wallet_from_mnemonic():

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

    wallet.from_mnemonic(
        mnemonic=_["ethereum"]["wallet"]["sender"]["mnemonic"],
        language=_["ethereum"]["wallet"]["sender"]["language"],
        passphrase=_["ethereum"]["wallet"]["sender"]["passphrase"])

    wallet.from_path(
        path=_["ethereum"]["wallet"]["sender"]["derivation"]["path"])

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