示例#1
0
def output(private_key):
    if private_key == 0:
        private_key = wallet.get_private_key()
    print("Your private key:\n" + private_key + "Please keep it in secret!!!")
    wif_key = wallet.convert_to_WIF(private_key)
    print("Your private key in wif format is:")
    print(wif_key)
    bitcoin_address = wallet.get_bitcoin_address(private_key)
    print("Your public address is:\n" + bitcoin_address +
          "\nYou can find it in the file address")
    f = open('address', 'a')
    f.write(bitcoin_address + "\n")
    return private_key
示例#2
0
 def __init__(self, height=0, reward=50):
     try:
         f = open('minerkey', 'r')
     except IOError:
         print("Create file mainerkey with WIF key!!")
         return
     private_key = wallet.WIF_to_key(f.read())
     inputik = []
     inputik.append(CoinbaseInput(height))
     bitcoin_address = wallet.get_bitcoin_address(private_key)
     print("Bitcoin address ", bitcoin_address)
     output = []
     output.append(Output(reward * pow(10, 8), bitcoin_address))
     Transaction.__init__(self, 1, inputik, output, 0)
logger = log_handlers.get_logger(config)
logger.debug("-------------------------ENVIRONMENT--------------------------")
logger.debug("Am I Local: %s " % config.is_local_host())

wallet = wallet.create_wallet(config.get_wallet_type(), config.get_key_id(),
                              logger)
secure_message = SecureMessage(wallet)

## Test GET pubkey
req_pubkey = requests.get(notary_url + '/api/v1/pubkey',
                          verify=config.get_ssl_verify_mode())
data = req_pubkey.json()
other_party_public_key = data['public_key']
print data['public_key']
address = str(wallet.get_bitcoin_address())

## Test POST account

print("\nWallet Public Key Hex %s" % wallet.get_public_key_hex())
print("\nWallet Public Key %s" % wallet.get_public_key())
addrfromhex = P2PKHBitcoinAddress.from_pubkey(
    wallet.get_public_key_hex().decode("hex"))
print("\nAddress From Hex %s" % addrfromhex)
email = test_data.email_address

registration_message = {
    'public_key': wallet.get_public_key_hex(),
    'email': email
}
logger = log_handlers.get_logger(config)
logger.debug("-------------------------ENVIRONMENT--------------------------")
logger.debug("Am I Local: %s " % config.is_local_host())

wallet = wallet.create_wallet(config.get_wallet_type(), config.get_key_id(),logger)
secure_message = SecureMessage(wallet)

## Test GET pubkey
pubkey_response = requests.get(notary_url+'/api/v1/pubkey', verify=False)
data = pubkey_response.json()
other_party_public_key_hex = data['public_key']
print data['public_key']
other_party_public_key_decoded = other_party_public_key_hex.decode("hex")
other_party_public_key = CPubKey(other_party_public_key_decoded)
other_party_address = P2PKHBitcoinAddress.from_pubkey(other_party_public_key)
address = str(wallet.get_bitcoin_address())

## Test GET challenge

response = requests.get(notary_url+'/api/v1/challenge/' + address, verify=False)
payload = json.loads(response.content)
if secure_message.verify_secure_payload(other_party_address, payload):
    message = secure_message.get_message_from_secure_payload(payload)
    print(message)

payload = secure_message.create_secure_payload(other_party_public_key_hex, message)
response = requests.put(notary_url+'/api/v1/challenge/' + address, data=payload, verify=False)
cookies = requests.utils.dict_from_cookiejar(response.cookies)

metadata = {
    'title': 'Stillwater Shame',
示例#5
0
import wallet
import configuration
import log_handlers

config = configuration.NotaryConfiguration('./notaryconfig.ini')
logger = log_handlers.get_logger(config)

# wallet = wallet.create_wallet('PlainWallet', keyId, logger=None)
wallet = wallet.create_wallet('ServerWallet', config, logger)
# wallet = wallet.create_wallet('ClientWallet', keyId, logger=None)
print("Wallet: Bitcoin Address %s " % wallet.get_bitcoin_address())
print("Wallet: Private Key WIF %s " % wallet.get_private_key_wif())
print("Wallet: Public Key Hex %s " % wallet.get_public_key_hex())
示例#6
0
from base58 import base58_check_encode
import os
from bitcoinlib.wallet import CBitcoinSecret, P2PKHBitcoinAddress
import requests
requests.packages.urllib3.disable_warnings()

def privateKeyToWif(key_hex):
    return base58_check_encode(0x80, key_hex.decode('hex'))

wallet = wallet.create_wallet(config.get_wallet_type(), config.get_key_id())

print("\nWallet Private Key %s" % wallet.get_private_key())
print("\nWallet Public Key %s" % wallet.get_public_key())
print("\nWallet Public Key Hex %s" % wallet.get_public_key_hex())
print("\nWallet Private Key WIF %s" % wallet.get_private_key_wif())
str = wallet.get_bitcoin_address()
print("\nWallet Address %s" % wallet.get_bitcoin_address())

pubkeyhex = wallet.get_public_key_hex()
pubkey = wallet.get_public_key()

addrfrom = P2PKHBitcoinAddress.from_pubkey(pubkey)
addrfromhex = P2PKHBitcoinAddress.from_pubkey(pubkeyhex.decode("hex"))
print("\nAddress From %s" % addrfrom)
print("\nAddress From Hex %s" % addrfromhex)

message = "bitid://localhost:5000/callback?x=30f56bc022dde976&u=1"

print("\nClear: %s" % message)
encrypted = encrypt.encrypt(wallet.get_public_key(), message)
print("\nEncrypted: %s" % encrypted)
示例#7
0
 def test_address_from_priv(self):
     private_key = 'e6b3a66524b26dd81d0841cc77d31a39aaefc157d6486487885b1cc7cd017a52'
     my_addr = wallet.get_bitcoin_address(private_key)
     self.assertEqual(my_addr, ADDR)
示例#8
0
import wallet
import configuration
import log_handlers


config = configuration.NotaryConfiguration('./notaryconfig.ini')
logger = log_handlers.get_logger(config)


# wallet = wallet.create_wallet('PlainWallet', keyId, logger=None)
wallet = wallet.create_wallet('ServerWallet', config, logger)
# wallet = wallet.create_wallet('ClientWallet', keyId, logger=None)
print("Wallet: Bitcoin Address %s " % wallet.get_bitcoin_address())
print("Wallet: Private Key WIF %s " % wallet.get_private_key_wif())
print("Wallet: Public Key Hex %s " % wallet.get_public_key_hex())