Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def exec_test():
QTest.mouseClick(transfer_dialog.view.radio_pubkey, Qt.LeftButton)
QTest.keyClicks(transfer_dialog.view.edit_pubkey, alice.key.pubkey)
transfer_dialog.view.spinbox_amount.setValue(10)
await asyncio.sleep(0.1)
assert not transfer_dialog.view.button_box.button(QDialogButtonBox.Ok).isEnabled()
await asyncio.sleep(0.1)
QTest.keyClicks(transfer_dialog.view.password_input.edit_secret_key, bob.salt)
QTest.keyClicks(transfer_dialog.view.password_input.edit_password, bob.password)
assert transfer_dialog.view.button_box.button(QDialogButtonBox.Ok).isEnabled()
QTest.mouseClick(transfer_dialog.view.button_box.button(QDialogButtonBox.Ok), Qt.LeftButton)
await asyncio.sleep(0.2)
assert isinstance(fake_server_with_blockchain.forge.pool[0], Transaction)
transfers_changed = []
new_transfers = {}
for connection in connections:
txid = 0
new_transfers[connection] = []
history_data = await self._bma_connector.get(self.currency, bma.tx.blocks,
req_args={'pubkey': connection.pubkey,
'start': start,
'end': end})
for tx_data in history_data["history"]["sent"]:
for tx in [t for t in self._transactions_processor.awaiting(self.currency)]:
if self._transactions_processor.run_state_transitions(tx, tx_data["hash"], tx_data["block_number"]):
transfers_changed.append(tx)
self._logger.debug("New transaction validated : {0}".format(tx.sha_hash))
for tx_data in history_data["history"]["received"]:
tx_doc = TransactionDoc.from_bma_history(history_data["currency"], tx_data)
if not self._transactions_processor.find_by_hash(connection.pubkey, tx_doc.sha_hash) \
and SimpleTransaction.is_simple(tx_doc):
tx = parse_transaction_doc(tx_doc, connection.pubkey, tx_data["block_number"],
tx_data["time"], txid)
if tx:
new_transfers[connection].append(tx)
self._transactions_processor.commit(tx)
else:
logging.debug("Error during transfer parsing")
return transfers_changed, new_transfers
if len(sources) > 40:
sources_value = 0
for s in sources[:39]:
sources_value += s.amount * (10**s.base)
sources_value, sources_base = reduce_base(sources_value, 0)
chained_tx = self.prepare_tx(key, key.pubkey, blockstamp,
sources_value, sources_base, "[CHAINED]", currency)
forged_tx += chained_tx
self._sources_processor.consume(sources)
logging.debug("Inputs : {0}".format(sources))
inputs = self.tx_inputs(sources)
unlocks = self.tx_unlocks(sources)
outputs = self.tx_outputs(key.pubkey, receiver, computed_outputs, overheads)
logging.debug("Outputs : {0}".format(outputs))
txdoc = TransactionDoc(10, currency, blockstamp, 0,
[key.pubkey], inputs, unlocks,
outputs, message, None)
txdoc.sign([key])
self.commit_outputs_to_self(currency, key.pubkey, txdoc)
time = self._blockchain_processor.time(currency)
tx = Transaction(currency=currency,
pubkey=key.pubkey,
sha_hash=txdoc.sha_hash,
written_block=0,
blockstamp=blockstamp,
timestamp=time,
signatures=txdoc.signatures,
issuers=[key.pubkey],
receivers=[receiver],
amount=amount,
amount_base=amount_base,
def txdoc(self):
"""
:rtype: duniterpy.documents.Transaction
"""
return TransactionDoc.from_signed_raw(self.raw)
dividend = Dividend(currency=connection.currency,
pubkey=connection.pubkey,
block_number=ud_data["block_number"],
timestamp=ud_data["time"],
amount=ud_data["amount"],
base=ud_data["base"])
log_stream("Dividend of block {0}".format(dividend.block_number))
block_numbers.append(dividend.block_number)
try:
dividends.append(dividend)
self._repo.insert(dividend)
except sqlite3.IntegrityError:
log_stream("Dividend already registered in database")
for tx in transactions:
txdoc = Transaction.from_signed_raw(tx.raw)
for input in txdoc.inputs:
if input.source == "D" and input.origin_id == connection.pubkey \
and input.index not in block_numbers and input.index > start:
diff_blocks = blockchain.current_buid.number - input.index
ud_mediantime = blockchain.median_time - diff_blocks*blockchain.parameters.avg_gen_time
dividend = Dividend(currency=connection.currency,
pubkey=connection.pubkey,
block_number=input.index,
timestamp=ud_mediantime,
amount=input.amount,
base=input.base)
log_stream("Dividend of block {0}".format(dividend.block_number))
try:
dividends.append(dividend)
self._repo.insert(dividend)
except sqlite3.IntegrityError:
index=0,
# unlock inputs[index] if signatures[0] is from public key of issuers[0]
parameters=[SIGParameter(0)],
)
]
# lists of outputs
outputs = [
OutputSource(
amount=source["amount"],
base=source["base"],
condition="SIG({0})".format(to_pubkey),
)
]
transaction = Transaction(
version=TRANSACTION_VERSION,
currency=current_block["currency"],
blockstamp=BlockUID(current_block["number"], current_block["hash"]),
locktime=0,
issuers=issuers,
inputs=inputs,
unlocks=unlocks,
outputs=outputs,
comment="",
signatures=[],
)
return transaction