def spawn(self, verify: bool = False, sign: bool = False, send: bool = False, locktime: int = 0, **kwargs): '''prepare deck spawn transaction''' deck = self.__new(**kwargs) spawn = pa.deck_spawn(provider=provider, inputs=provider.select_inputs( Settings.key.address, 0.02), deck=deck, change_address=Settings.change, locktime=locktime) if verify: return cointoolkit_verify( spawn.hexlify()) # link to cointoolkit - verify if sign: tx = signtx(spawn) if send: return sendtx(tx) return tx.hexlify() return spawn.hexlify()
def new_deck(provider, deck): ''' Spawn a new PeerAssets deck. pacli deck -new '{"name": "test", "number_of_decimals": 1, "issue_mode": "ONCE"}' Will return deck span txid. ''' deck = json.loads(deck) deck["network"] = Settings.network utxo = provider.select_inputs(0.02) ## we need 0.02 PPC change_address = change(utxo) raw_deck = pa.deck_spawn(pa.Deck(**deck), inputs=utxo, change_address=change_address, prod=Settings.prod) raw_deck_spawn = hexlify(raw_deck).decode() signed = provider.signrawtransaction(raw_deck_spawn) txid = provider.sendrawtransaction(signed["hex"]) print("\n", txid, "\n") deck["asset_id"] = txid d = pa.Deck(**deck) pa.load_deck_p2th_into_local_node(provider, d) # subscribe to deck
def new(deck, broadcast): ''' Spawn a new PeerAssets deck. Returns the deck span txid. [deck] is deck description json. I.E. '{"name": "test", "number_of_decimals": 1, "issue_mode": "ONCE"}' ''' deck = json.loads(deck) deck["network"] = Settings.network deck["production"] = Settings.production deck["version"] = Settings.deck_version #utxo = provider.select_inputs(0.02) # we need 0.02 PPC utxo = default_account_utxo(0.02) if utxo: change_address = change(utxo) else: return raw_deck = pa.deck_spawn(pa.Deck(**deck), inputs=utxo, change_address=change_address) raw_deck_spawn = hexlify(raw_deck).decode() signed = provider.signrawtransaction(raw_deck_spawn) if broadcast: txid = provider.sendrawtransaction(signed["hex"]) print("\n", txid, "\n") deck["asset_id"] = txid d = pa.Deck(**deck) pa.load_deck_p2th_into_local_node(provider, d) # subscribe to deck else: print("\nraw transaction:\n", signed["hex"], "\n")
def test_deck_spawn(): provider = Explorer(network='tppc') inputs = provider.select_inputs("mthKQHpr7zUbMvLcj8GHs33mVcf91DtN6L", 0.02) change_address = "mthKQHpr7zUbMvLcj8GHs33mVcf91DtN6L" deck = pa.Deck(name="just-testing.", number_of_decimals=1, issue_mode=1, network='tppc', production=True, version=1, asset_specific_data='https://talk.peercoin.net/') deck_spawn = pa.deck_spawn(provider, deck, inputs, change_address) assert isinstance(deck_spawn, MutableTransaction)
def spawn(self, verify=False, **kwargs): '''prepare deck spawn transaction''' deck = self.__new(**kwargs) spawn = pa.deck_spawn(provider=provider, inputs=provider.select_inputs( Settings.key.address, 0.02), deck=deck, change_address=Settings.change) if verify: return cointoolkit_verify( spawn.hexlify()) # link to cointoolkit - verify return spawn.hexlify()
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) ]) deck = pa.Deck(name=name, number_of_decimals=3, issue_mode=4, version=1, fee=0) unspent = provider.select_inputs(key.address, 0.02) new_deck = pa.deck_spawn(provider, key, deck, unspent, change_addr) Session.deck = deck print(new_deck)
''' Spawn new PeerAssets deck on Peercoin testnet using local testnet node. ''' import pypeerassets as pa from binascii import hexlify provider = pa.RpcNode(testnet=True) utxo = provider.select_inputs(0.02) ## we need 0.02 PPC change_addr = "mwkFUPUrh6LsXyMvBY2mz6btiJjuTxGgT8" new_deck = pa.Deck("my_new_testnet_deck", number_of_decimals=2, issue_mode="MULTI", asset_specific_data="hello world.", network="tppc") raw_tx = hexlify(pa.deck_spawn(new_deck, utxo, change_addr)).decode() signed = provider.signrawtransaction(raw_tx) provider.sendrawtransaction(signed["hex"]) # send the tx ''' Now wait for the tx confirm (1) and visit http://137.74.40.81:4000/ to see your assets listed. '''
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, ) deck_spawn_tx = pa.deck_spawn( provider=rpc_node, deck=deck, inputs=rpc_node.select_inputs(FRIENDLY_CO, 0.02), change_address=FRIENDLY_CO, ) deck_spawn_tx = sign_transaction(rpc_node, deck_spawn_tx, friendly_co_key) rpc_node.sendrawtransaction(deck_spawn_tx.hexlify()) print("Transaction to create the Friendly Co. Deck sent to the network!") print("Transaction ID: " + deck_spawn_tx.txid) print("Waiting for confirmation...") wait_for_confirmation(rpc_node, deck_spawn_tx.txid) print("Friendly Co. Deck created!") deck.id = deck_spawn_tx.txid print("Deck ID: " + deck.id) print("Deck P2TH Address: " + deck.p2th_address) print("Double checking that the Friendly Co. Deck exists...")