Compare commits
2 Commits
36533929ca
...
21bda9d646
Author | SHA1 | Date |
---|---|---|
poka | 21bda9d646 | |
poka | 481d13269d |
|
@ -21,9 +21,14 @@ if not node:
|
|||
# Parse arguments
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-p', '--pubkey', help="Clé publique du compte visé")
|
||||
parser.add_argument('-n', '--node', help="Sélection d'un noeud Duniter à utiliser")
|
||||
parser.add_argument('-k', '--key', help="Chemin vers notre fichier de trousseau (PubSec)")
|
||||
parser.add_argument('--mempool', action='store_true', help="Utilise les sources en Mempool")
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.node: node = args.node
|
||||
if args.key: dunikey = args.key
|
||||
|
||||
# Create transaction and send it
|
||||
hist = History(dunikey, node, args.pubkey, args.mempool)
|
||||
result = hist.history()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import sys, re, os.path, json, ast
|
||||
import sys, re, os.path, json, ast, time
|
||||
from datetime import datetime
|
||||
from termcolor import colored
|
||||
from lib.natools import fmt, sign, get_privkey
|
||||
|
@ -41,6 +41,16 @@ class History:
|
|||
outputs
|
||||
comment
|
||||
}
|
||||
receiving {
|
||||
issuers
|
||||
outputs
|
||||
comment
|
||||
}
|
||||
sending {
|
||||
issuers
|
||||
outputs
|
||||
comment
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
@ -85,7 +95,33 @@ class History:
|
|||
transOut[i].append(bloc['comment'])
|
||||
i += 1
|
||||
|
||||
trans = transIn + transOut
|
||||
res = self.historyDoc['transactionsHistory']['receiving']
|
||||
transInMempool=[[0 for x in range(0)] for y in range(len(res))]
|
||||
for i, bloc in enumerate(res):
|
||||
for output in bloc['outputs']:
|
||||
if re.search(self.pubkey, output):
|
||||
transInMempool[i].append("INM")
|
||||
transInMempool[i].append(int(time.time()))
|
||||
transInMempool[i].append(bloc['issuers'][0])
|
||||
transInMempool[i].append(int(output.split(':')[0])/100)
|
||||
transInMempool[i].append(bloc['comment'])
|
||||
|
||||
res = self.historyDoc['transactionsHistory']['sending']
|
||||
transOutMempool=[[0 for x in range(0)] for y in range(len(res))]
|
||||
i = 0
|
||||
for bloc in res:
|
||||
for output in bloc['outputs']:
|
||||
if not re.search(self.pubkey, output):
|
||||
transOutMempool[i].append("OUTM")
|
||||
transOutMempool[i].append(int(time.time()))
|
||||
transOutMempool[i].append(output.split("SIG(")[1].replace(')',''))
|
||||
transOutMempool[i].append(int(output.split(':')[0])/100)
|
||||
transOutMempool[i].append(bloc['comment'])
|
||||
i += 1
|
||||
|
||||
|
||||
|
||||
trans = transIn + transOut + transInMempool + transOutMempool
|
||||
trans = list(filter(None, trans))
|
||||
trans.sort(key=lambda x: x[1])
|
||||
|
||||
|
@ -93,16 +129,23 @@ class History:
|
|||
rows = int(os.popen('stty size', 'r').read().split()[1])
|
||||
|
||||
print('-'.center(rows, '-'))
|
||||
print("{: <20} | {: <45} | {: <7} | {: <30}".format(" Date"," De la part de (clé publique)","Montant","Commentaire"))
|
||||
print("{: <20} | {: <45} | {: <7} | {: <30}".format(" Date"," De / À (clé publique)","Montant","Commentaire"))
|
||||
for i in trans:
|
||||
color = "green" if i[0] == "IN" else "blue"
|
||||
if i[0] == "IN":
|
||||
color = "green"
|
||||
elif i[0] == "INM":
|
||||
color = "yellow"
|
||||
elif i[0] == "OUTM":
|
||||
color = "red"
|
||||
else: color = "blue"
|
||||
|
||||
date = datetime.fromtimestamp(i[1]).strftime("%d/%m/%Y à %H:%M")
|
||||
print('-'.center(rows, '-'))
|
||||
print(colored("{: <20} | {: <45} | {: <7} | {: <30}".format(date, *i[2:]), color))
|
||||
# print(*i)
|
||||
|
||||
print('-'.center(rows, '-'))
|
||||
|
||||
def history(self):
|
||||
self.sendDoc()
|
||||
self.parseHistory()
|
||||
|
||||
|
||||
|
|
5
pay.py
5
pay.py
|
@ -25,6 +25,8 @@ parser = argparse.ArgumentParser()
|
|||
parser.add_argument('-d', '--destinataire', help="Destinataire du paiement")
|
||||
parser.add_argument('-m', '--montant', type=int, help="Montant de la transaction")
|
||||
parser.add_argument('-c', '--commentaire', default="", help="Commentaire de la transaction")
|
||||
parser.add_argument('-n', '--node', help="Sélection d'un noeud Duniter à utiliser")
|
||||
parser.add_argument('-k', '--key', help="Chemin vers notre fichier de trousseau (PubSec)")
|
||||
parser.add_argument('--mempool', action='store_true', help="Utilise les sources en Mempool")
|
||||
parser.add_argument('-v', '--verbose', action='store_true', help="Affiche le résultat JSON de la transaction")
|
||||
parser.add_argument('--version', action='store_true', help="Affiche la version actuelle du programme")
|
||||
|
@ -39,6 +41,9 @@ if not args.destinataire or not args.montant:
|
|||
parser.print_help()
|
||||
sys.exit(1)
|
||||
|
||||
if args.node: node = args.node
|
||||
if args.key: dunikey = args.key
|
||||
|
||||
# Create transaction and send it
|
||||
trans = Transaction(dunikey, node, args.destinataire, args.montant, args.commentaire, args.mempool, args.verbose)
|
||||
result = trans.send()
|
||||
|
|
Reference in New Issue