-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmain.cpp
More file actions
72 lines (53 loc) · 2.05 KB
/
Copy pathmain.cpp
File metadata and controls
72 lines (53 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <QApplication>
#include "Bingot.h"
#include <QDebug>
#include <QJsonDocument>
#include <QJsonObject>
#include "BigInt.h"
#include "Miner.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
qDebug() << "test";
Bingot *bingot = new Bingot();
bingot->initialize();
qDebug() << "address:" << bingot->address();
qDebug() << "privatekey:" << bingot->privateKey();
qDebug() << "publicKey:" << bingot->publicKey();
Transaction t(bingot->address(), QString("random_address").toLocal8Bit(), 53);
t.signTransaction(bingot->privateKey(), bingot->publicKey());
if (t.verifySignature())
{
qDebug() << "signature can be verified";
}
qDebug() << "from" << t.getFromAddress();
qDebug() << "to" << t.getToAddress();
QByteArray transJson = t.getMessageJson();
Transaction t2;
t2.parseFromJsonObject(QJsonDocument::fromJson(transJson).object());
qDebug() << "t1 == t2?" << (t == t2);
qDebug() << "verify t2 signature" << t2.verifySignature();
qDebug() << "t2" << t2.getMessageJson();
BigInt a1(0x1FF);
qDebug() << "created";
qDebug() << a1.getData().toHex() << Miner::countLeadingZeros(a1.getData());
a1.increase();
qDebug() << a1.getData().toHex() << Miner::countLeadingZeros(a1.getData());
a1.increase();
qDebug() <<a1.getData().toHex()<< Miner::countLeadingZeros(a1.getData());
a1.increase();
qDebug() <<a1.getData().toHex()<< Miner::countLeadingZeros(a1.getData());
QHash<QByteArray, Transaction> h;
h.insert(t.getSignature(), t);
Block b(1, h, QString("random_prehash").toLocal8Bit());
qDebug() << b.getCacheBlockHash();
qDebug() << b.toJson();
qDebug() << b.toMessageJson();
Block b2;
b2.parseFromQJsonObject(QJsonDocument::fromJson( b.toMessageJson()).object());
qDebug() << "b2:"<< b2.toMessageJson();
Miner *m_miner = new Miner(b2, 0, 20000000000000);
m_miner->moveToThread(m_miner);
m_miner->start();
return a.exec();
}