Skip to content
Snippets Groups Projects
Commit a1869885 authored by Evgenii Tagiltsev's avatar Evgenii Tagiltsev
Browse files

[*] changed regexp for getWallets

parent 08144ab9
No related branches found
No related tags found
1 merge request!27Bugs 2588
Pipeline #994 passed with stage
in 3 minutes and 28 seconds
#include "DapChainWalletHandler.h"
#include <QDebug>
#include <QRegularExpression>
DapChainWalletHandler::DapChainWalletHandler(QObject *parent) : QObject(parent)
{
......@@ -42,27 +43,36 @@ QMap<QString, QVariant> DapChainWalletHandler::getWallets()
QProcess process;
process.start(QString("%1 wallet list").arg(CLI_PATH));
process.waitForFinished(-1);
QString str = QString::fromLatin1(process.readAll());
QRegExp rx(":{1,1}([\\s\\w\\W]+)(\\n|\\r){1,1}" );
rx.setMinimal(true);
int pos = 0;
int x {0};
QString tempName;
while ((pos = rx.indexIn(str, pos)) != -1)
{
if(x == 0)
{
tempName = rx.cap(1);
++x;
}
else
{
map.insert(tempName, rx.cap(1));
x = 0;
}
pos += rx.matchedLength();
QByteArray result = process.readAll();
QRegularExpression rx("wallet:\\s(.+)\\s+addr:\\s(.+)", QRegularExpression::MultilineOption);
QRegularExpressionMatchIterator itr = rx.globalMatch(result);
while (itr.hasNext()) {
QRegularExpressionMatch match = itr.next();
map[match.captured(1)] = match.captured(2);
}
// QString str = QString::fromLatin1(process.readAll());
// QRegExp rx(":{1,1}([\\s\\w\\W]+)(\\n|\\r){1,1}" );
// rx.setMinimal(true);
// int pos = 0;
// int x {0};
// QString tempName;
// while ((pos = rx.indexIn(str, pos)) != -1)
// {
// if(x == 0)
// {
// tempName = rx.cap(1);
// ++x;
// }
// else
// {
// map.insert(tempName, rx.cap(1));
// x = 0;
// }
// pos += rx.matchedLength();
// }
return map;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment