Exemple #1
0
def test_bitcoin_wallet_tools():
    wallet = Wallet(network="testnet")
    private_key = "92cbbc5990cb5090326a76feeb321cad01048635afe5756523bbf9f7a75bf38b"
    public_key = wallet.public_key(private_key=private_key)
    assert public_key == "03c56a6005d4a8892d28cc3f7265e5685b548627d59108973e474c4e26f69a4c84"
    public_key = "04c56a6005d4a8892d28cc3f7265e5685b548627d59108973e474c4e26f69a4c84fee63d89a5979801c96" \
                 "5994963c77bfb470dff5afd351a442ebf329f3b2c2835"

    compressed = wallet.compressed(public_key=public_key)
    assert compressed == "03c56a6005d4a8892d28cc3f7265e5685b548627d59108973e474c4e26f69a4c84"
    uncompressed = wallet.uncompressed(public_key=public_key)
    assert uncompressed == public_key
    address = wallet.address(public_key=uncompressed)
    assert address == "mqLyrNDjpENRMZAoDpspH7kR9RtgvhWzYE"
    _hash = wallet.hash(public_key=uncompressed)
    assert _hash == "6bce65e58a50b97989930e9a4ff1ac1a77515ef1"
    p2pkh = wallet.p2pkh(address=address)
    assert p2pkh == "76a9146bce65e58a50b97989930e9a4ff1ac1a77515ef188ac"
    p2sh = wallet.p2sh(address=address)
    assert p2sh == "a914347283eee92ad685909044619adaa70370b2538787"
    balance = wallet.balance(address=address, network="testnet")
    assert isinstance(balance, int)
    unspent = wallet.unspent(address=address, network="testnet", limit=1)
    assert isinstance(unspent, list)
Exemple #2
0
print("Sender Private Key:", sender_private_key)
sender_public_key = sender_wallet.public_key()
print("Sender Public Key:", sender_public_key)
sender_compressed = sender_wallet.compressed()
print("Sender Compressed:", sender_compressed)
sender_uncompressed = sender_wallet.uncompressed()
print("Sender Uncompressed:", sender_uncompressed)
sender_address = sender_wallet.address()
print("Sender Address:", sender_address)
sender_hash = sender_wallet.hash()
print("Sender Hash:", sender_hash)
sender_p2pkh = sender_wallet.p2pkh()
print("Sender P2PKH:", sender_p2pkh)
sender_p2sh = sender_wallet.p2sh()
print("Sender P2SH:", sender_p2sh)
sender_balance = sender_wallet.balance()
print("Sender Balance:", sender_balance)
# sender_unspent = sender_wallet.unspent()
# for index, unspent in enumerate(sender_unspent):
#     print("Sender %d Unspent" % index, unspent)

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

# Initialize recipient bitcoin wallet
recipient_wallet = Wallet(network=network)
recipient_wallet.from_address("muTnffLDR5LtFeLR2i3WsKVfdyvzfyPnVB")
# Getting wallet information's
recipient_address = recipient_wallet.address()
print("Recipient Address:", recipient_address)
recipient_hash = recipient_wallet.hash()
print("Recipient Hash:", recipient_hash)
Exemple #3
0
print("Recipient Private Key:", recipient_private_key)
recipient_public_key = recipient_wallet.public_key()
print("Recipient Public Key:", recipient_public_key)
recipient_compressed = recipient_wallet.compressed()
print("Recipient Compressed:", recipient_compressed)
recipient_uncompressed = recipient_wallet.uncompressed()
print("Recipient Uncompressed:", recipient_uncompressed)
recipient_address = recipient_wallet.address()
print("Recipient Address:", recipient_address)
recipient_hash = recipient_wallet.hash()
print("Recipient Hash:", recipient_hash)
recipient_p2pkh = recipient_wallet.p2pkh()
print("Recipient P2PKH:", recipient_p2pkh)
recipient_p2sh = recipient_wallet.p2sh()
print("Recipient P2SH:", recipient_p2sh)
recipient_balance = recipient_wallet.balance()
print("Recipient Balance:", recipient_balance, "Satoshi")
# recipient_unspent = recipient_wallet.unspent()
# for index, unspent in enumerate(recipient_unspent):
#     print("Recipient %d Unspent" % index, unspent)

print("=" * 10, "Hash Time Lock Contract (HTLC) Fund Transaction Id")

# Funded hash time lock contract transaction id/hash
fund_transaction_id = "f7a709ffe08856d7539a155b857913e69e1e6ab4079a47d1c4b94eaa38982768"
print("HTLC Fund Transaction Id:", fund_transaction_id)

print("=" * 10, "Unsigned Claim Transaction")

# Initialization claim transaction
unsigned_claim_transaction = ClaimTransaction(version=2, network=network)