Esempio n. 1
0
def load_deck_p2th_into_local_node(provider: RpcNode, deck: Deck) -> None:
    '''
    load deck p2th into local node via "importprivke",
    this allows building of proof-of-timeline for this deck
    '''

    assert isinstance(provider, RpcNode), {"error": "You can load privkeys only into local node."}
    error = {"error": "Deck P2TH import went wrong."}

    provider.importprivkey(deck.p2th_wif, deck.id)
    check_addr = provider.validateaddress(deck.p2th_address)

    if not check_addr["isvalid"] and not check_addr["ismine"]:
        raise DeckP2THImportError(error)
Esempio n. 2
0
def load_p2th_privkey_into_local_node(provider: RpcNode, prod: bool=True) -> None:
    '''Load PeerAssets P2TH privkey into the local node.'''

    assert isinstance(provider, RpcNode), {"error": "Import only works with local node."}
    error = {"error": "Loading P2TH privkey failed."}
    pa_params = param_query(provider.network)

    if prod:
        provider.importprivkey(pa_params.P2TH_wif, "PAPROD")
        #  now verify if ismine == True
        if not provider.validateaddress(pa_params.P2TH_addr)['ismine']:
            raise P2THImportFailed(error)
    else:
        provider.importprivkey(pa_params.test_P2TH_wif, "PATEST")
        if not provider.validateaddress(pa_params.test_P2TH_addr)['ismine']:
            raise P2THImportFailed(error)
Esempio n. 3
0
"""find <address> card balance on this <deck>"""

import pypeerassets as pa
from pypeerassets.provider import RpcNode
from pypeerassets.protocol import DeckState

provider = RpcNode(testnet=True)
state = None



def get_state(deck):
    deck = pa.find_deck(provider,deck)[0]
    cards = pa.find_card_transfers(provider,deck)
    return DeckState(cards)

def get_balance(state, address):
    print(state.balances[address])

def get_balances(state):
    print(state.balances)

def get_total(state):
    print(state.total)

def get_checksum(state):
    print(state.checksum)
    
def get_burned(state):
    print(state.burned)
    
Esempio n. 4
0
def wait_for_confirmation(provider, transaction_id):
    'Sleep on a loop until we see a confirmation of the transaction.'
    while(True):
        transaction = provider.gettransaction(transaction_id)
        if transaction["confirmations"] > 0:
            break
        time.sleep(10)


if __name__ == "__main__":

    # Deck Spawn

    print("Build, sign and send the Friendly Co. Deck spawning transaction...")

    rpc_node = RpcNode(testnet=True, username=RPC_USERNAME, password=RPC_PASSWORD)

    friendly_co_key = pa.Kutil(
        network="tppc",
        from_wif=rpc_node.dumpprivkey(FRIENDLY_CO),
    )

    deck = pa.Deck(
        name="Friendly Co. Deck",
        number_of_decimals=0,
        issue_mode=IssueMode.ONCE.value,
        network="tppc",
        production=False,
        version=1,
        issuer=FRIENDLY_CO,
    )