Commit e518e81b authored by Pascal Engélibert's avatar Pascal Engélibert

Exceptions on sendTransaction

parent ff29b6fb
......@@ -245,16 +245,26 @@ def mix(db_txs, amount, base, sender, path, host, proxy=None, proxy_onion_only=F
print("Remind: no-tx mode")
if input("OK? [yn]: ").lower() == "y":
db_txs.put(comment_seeds[0][1], PublicKey(sender.pubkey).encrypt_seal(ubjson.dumpb({
message = {
"sender": sender.pubkey,
"path": path,
"amount": amount,
"onetime_keys": [ot_keys.hex_sk().decode() for ot_keys in onetime_keys],
"confirms": [confirm.to_dict() for confirm in confirms]
})))
"confirms": [confirm.to_dict() for confirm in confirms],
"sent": False
}
db_txs.put(comment_seeds[0][1], PublicKey(sender.pubkey).encrypt_seal(ubjson.dumpb(message)))
if send_tx:
sendTransaction(sender, path[0], amount, gen_comment(comment_seeds[0]))
try:
sendTransaction(sender, path[0], amount, gen_comment(comment_seeds[0]))
message["sent"] = True
db_txs.put(comment_seeds[0][1], PublicKey(sender.pubkey).encrypt_seal(ubjson.dumpb(message)))
except socket.timeout:
logPrint("Error when sending tx: timeout", LOG_ERROR)
except Exception as e:
logPrint("Error when sending tx: " + str(e), LOG_ERROR)
return
async def test1(db_txs, host, receiver, amount=1000, layers=3, proxy=None, proxy_onion_only=False, send_tx=True):
......
......@@ -606,8 +606,10 @@ class ClientThread(Thread):
sendTransaction(self.keys, tx.receiver_pubkey, tx.out_amount, gen_comment(tx.out_seeds))
tx.tx_sent = True
tx.export_ubjson(self.db_txs)
except socket.timeout:
logPrint("Error when sending tx: timeout", LOG_ERROR)
except Exception as e:
logPrint("Error when sending tx:\n" + str(e), LOG_ERROR)
logPrint("Error when sending tx: " + str(e), LOG_ERROR)
else:
logPrint("Not enough ready txs to mix (only "+str(len(ready_txs))+")", LOG_TRACE)
......
......@@ -172,6 +172,6 @@ def writePeers(dir, peers):
def sendTransaction(sender_keys, receiver_pubkey, amount, comment):
sender_amount = silkaj.money.get_amount_from_pubkey(sender_keys.pubkey)[0]
assert sender_amount >= amount
assert sender_amount >= amount, "not enough money"
silkaj.tx.generate_and_send_transaction(sender_keys.hex_seed().decode(), sender_keys.pubkey, amount, [receiver_pubkey], comment)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment