예제 #1
0
def test_from_passphrase():
    passphrase = "meheret tesfaye batu bayou".encode()
    # Initialize bitcoin wallet
    bitcoin_from_passphrase = Wallet(network="testnet") \
        .from_passphrase(passphrase)

    bitcoin_from_private_key = Wallet(network="testnet") \
        .from_private_key("92cbbc5990cb5090326a76feeb321cad01048635afe5756523bbf9f7a75bf38b")

    private_key = "92cbbc5990cb5090326a76feeb321cad01048635afe5756523bbf9f7a75bf38b"
    assert bitcoin_from_private_key.private_key(
    ) == private_key == bitcoin_from_passphrase.private_key()

    public_key = "03c56a6005d4a8892d28cc3f7265e5685b548627d59108973e474c4e26f69a4c84"
    assert bitcoin_from_private_key.public_key() == public_key

    address = "mphBPZf15cRFcL5tUq6mCbE84XobZ1vg7Q"
    assert bitcoin_from_private_key.address() == address

    # Initialize bitcoin wallet
    bitcoin_from_passphrase = Wallet(network="testnet")\
        .from_passphrase(passphrase, False)

    private_key = "92cbbc5990cb5090326a76feeb321cad01048635afe5756523bbf9f7a75bf38b"
    assert bitcoin_from_passphrase.private_key() == private_key

    public_key = "04c56a6005d4a8892d28cc3f7265e5685b548627d59108973e474c4e26f69a4c84fee63d89a5979801c9659" \
                 "94963c77bfb470dff5afd351a442ebf329f3b2c2835"
    assert bitcoin_from_passphrase.public_key() == public_key

    compressed = "03c56a6005d4a8892d28cc3f7265e5685b548627d59108973e474c4e26f69a4c84"
    assert bitcoin_from_passphrase.compressed() == compressed

    uncompressed = "04c56a6005d4a8892d28cc3f7265e5685b548627d59108973e474c4e26f69a4c84fee63d89a5979801c96" \
                   "5994963c77bfb470dff5afd351a442ebf329f3b2c2835"
    assert bitcoin_from_passphrase.uncompressed() == uncompressed

    assert bitcoin_from_passphrase.uncompressed(
    ) == bitcoin_from_passphrase.public_key()

    address = "mqLyrNDjpENRMZAoDpspH7kR9RtgvhWzYE"
    assert bitcoin_from_passphrase.address() == address

    _hash = "6bce65e58a50b97989930e9a4ff1ac1a77515ef1"
    assert bitcoin_from_passphrase.hash() == _hash

    p2pkh = "76a9146bce65e58a50b97989930e9a4ff1ac1a77515ef188ac"
    assert bitcoin_from_passphrase.p2pkh() == p2pkh

    p2sh = "a914347283eee92ad685909044619adaa70370b2538787"
    assert bitcoin_from_passphrase.p2sh() == p2sh
예제 #2
0
#!/usr/bin/env python3

from shuttle.providers.bitcoin.wallet import Wallet
from shuttle.providers.bitcoin.transaction import ClaimTransaction
from shuttle.providers.bitcoin.solver import ClaimSolver
from shuttle.providers.bitcoin.signature import ClaimSignature, Signature

network = "testnet"
recipient_passphrase = "meheret".encode()

# Initialize recipient bitcoin wallet
recipient_wallet = Wallet(network=network)\
    .from_passphrase(recipient_passphrase)
recipient_private_key = recipient_wallet.private_key()
# Funded hash time lock contract transaction id/hash
fund_transaction_id = "91f3a0dc0621f78be74a971dfb35d75255426d273f766456d9975006ece78b88"


# Testing bitcoin claim
def test_bitcoin_claim():
    # Initialization claim transaction
    unsigned_claim_transaction = ClaimTransaction(version=2, network=network)
    # Building claim transaction
    unsigned_claim_transaction.build_transaction(
        transaction_id=fund_transaction_id,
        wallet=recipient_wallet,
        amount=2000)

    assert unsigned_claim_transaction.fee == 576
    assert unsigned_claim_transaction.hash(
    ) == "726e390af02215d346be089dff566ae070f7332e8927d83acbb40b0e9105a787"
예제 #3
0
파일: fund.py 프로젝트: xeroc/shuttle
import json

# Setting network
# mainnet or testnet
network = "testnet"

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

sender_passphrase = "meheret tesfaye batu bayou".encode()
print("Sender Passphrase:", sender_passphrase.decode())

# Initialize sender bitcoin wallet
sender_wallet = Wallet(network=network)
sender_wallet.from_passphrase(sender_passphrase)
# Getting wallet information's
sender_private_key = sender_wallet.private_key()
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)