def test_sign_transaction():

    network_params = net_query('tppc')

    provider = pa.Cryptoid(network='tppc')
    key = pa.Kutil(
        network='tppc',
        privkey=bytearray.fromhex(
            '9e321f5379c2d1c4327c12227e1226a7c2e08342d88431dcbb0063e1e715a36c')
    )
    dest_address = pa.Kutil(network='tppc').address
    unspent = provider.select_inputs(key.address, 1)

    output = tx_output(network='tppc',
                       value=Decimal(0.1),
                       n=0,
                       script=p2pkh_script(network='tppc',
                                           address=dest_address))

    unsigned = PeercoinMutableTx(version=1,
                                 timestamp=int(time.time()),
                                 ins=unspent['utxos'],
                                 outs=[output],
                                 locktime=Locktime(0),
                                 network=network_params.btcpy_constants)

    assert isinstance(sign_transaction(provider, unsigned, key), Transaction)
示例#2
0
def test_find_cards():

    provider = pa.Cryptoid(network="tppc")

    deck = pa.find_deck(provider, 'b6a95f94fef093ee9009b04a09ecb9cb5cba20ab6f13fe0926aeb27b8671df43', 1)

    cards = pa.find_card_transfers(provider, deck)

    assert cards
    assert isinstance(cards[0], pa.CardTransfer)
示例#3
0
def test_find_deck():

    provider = pa.Cryptoid(network="tppc")

    deck = pa.find_deck(provider, 'b6a95f94fef093ee9009b04a09ecb9cb5cba20ab6f13fe0926aeb27b8671df43', 1)

    assert deck.__dict__ == {'asset_specific_data': b'',
                             'id': 'b6a95f94fef093ee9009b04a09ecb9cb5cba20ab6f13fe0926aeb27b8671df43',
                             'issue_mode': 4,
                             'issue_time': 1488840533,
                             'issuer': 'msYThv5bf7KjhHT1Cj5D7Y1tofyhq9vhWM',
                             'name': 'hopium_v2',
                             'network': 'peercoin-testnet',
                             'number_of_decimals': 2,
                             'production': True,
                             'testnet': True,
                             'version': 1
                             }
MAX_BURNS = 800

import pypeerassets as pa
from decimal import Decimal
import string
import random
import datetime, time
import pickle
import logging

logging.basicConfig(filename='pypa_simulation.log', level=logging.INFO)
logging.info("Started new session: {0}".format(
    datetime.datetime.now().isoformat()))

wif = 'cRvV1mhVvr9FTkGdUYkYXcBbomNgAmpfzhvhTep861thfp6noqyy'
provider = pa.Cryptoid(network='tppc')
change_addr = pa.Kutil(wif=wif, network='peercoin-testnet').address


class Session:
    '''temporary variable store'''
    pass


def deck_spawn():
    '''spawn a new, random deck'''

    key = pa.Kutil(wif=wif, network='peercoin-testnet')

    name = ''.join([
        random.choice(string.ascii_letters + string.digits) for n in range(8)
示例#5
0
'''
Find card transfers for <deck>.
'''

import sys
import pypeerassets as pa
provider = pa.Cryptoid(network="tppc")

print("Searching for deck {deck}.".format(deck=sys.argv[1]))
deck = pa.find_deck(provider, sys.argv[1])[0]
cards = pa.find_card_transfers(provider, deck)

print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
print(
    "This deck issuer has issued: {cards} cards in {transfers} card issue transactions."
    .format(cards=round(
        sum((i.amount[0] for i in cards if i.type == "CardIssue")),
        deck.number_of_decimals),
            transfers=len([i for i in cards if i.type == "CardIssue"])))

print(
    "Peers on this deck have transacted {cards} cards in {transfers} card transactions."
    .format(cards=round(
        sum((i.amount[0] for i in cards if i.type == "CardTransfer")),
        deck.number_of_decimals),
            transfers=len([i for i in cards if i.type == "CardTransfer"])))

print(
    "Peers on this deck have burned {cards} cards in {transfers} card transactions."
    .format(cards=round(
        sum((i.amount[0] for i in cards if i.type == "CardBurn")),