Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cellframe-ui-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cellframe
cellframe-ui-sdk
Commits
4e3d5ca3
Commit
4e3d5ca3
authored
5 years ago
by
andrey.daragan
Browse files
Options
Downloads
Patches
Plain Diff
bugs-3224
parent
65fe0a6d
No related branches found
No related tags found
1 merge request
!1
Support 3702
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
handlers/DapGetWalletsInfoCommand.cpp
+121
-0
121 additions, 0 deletions
handlers/DapGetWalletsInfoCommand.cpp
handlers/DapGetWalletsInfoCommand.h
+38
-0
38 additions, 0 deletions
handlers/DapGetWalletsInfoCommand.h
libdap-qt-ui-chain-wallet.pri
+2
-0
2 additions, 0 deletions
libdap-qt-ui-chain-wallet.pri
with
161 additions
and
0 deletions
handlers/DapGetWalletsInfoCommand.cpp
0 → 100644
+
121
−
0
View file @
4e3d5ca3
#include
"DapGetWalletsInfoCommand.h"
/// Overloaded constructor.
/// @param asServiceName Service name.
/// @param parent Parent.
/// @details The parent must be either DapRPCSocket or DapRPCLocalServer.
/// @param asCliPath The path to cli nodes.
DapGetWalletsInfoCommand
::
DapGetWalletsInfoCommand
(
const
QString
&
asServicename
,
QObject
*
parent
,
const
QString
&
asCliPath
)
:
DapAbstractCommand
(
asServicename
,
parent
,
asCliPath
)
{
}
/// Send a response to the client.
/// @details Performed on the service side.
/// @param arg1...arg10 Parameters.
/// @return Reply to client.
QVariant
DapGetWalletsInfoCommand
::
respondToClient
(
const
QVariant
&
arg1
,
const
QVariant
&
arg2
,
const
QVariant
&
arg3
,
const
QVariant
&
arg4
,
const
QVariant
&
arg5
,
const
QVariant
&
arg6
,
const
QVariant
&
arg7
,
const
QVariant
&
arg8
,
const
QVariant
&
arg9
,
const
QVariant
&
arg10
)
{
Q_UNUSED
(
arg1
)
Q_UNUSED
(
arg2
)
Q_UNUSED
(
arg3
)
Q_UNUSED
(
arg4
)
Q_UNUSED
(
arg5
)
Q_UNUSED
(
arg6
)
Q_UNUSED
(
arg7
)
Q_UNUSED
(
arg8
)
Q_UNUSED
(
arg9
)
Q_UNUSED
(
arg10
)
QList
<
DapWallet
>
wallets
;
QStringList
list
;
QProcess
processN
;
processN
.
start
(
QString
(
"%1 net list"
).
arg
(
m_sCliPath
));
processN
.
waitForFinished
(
-
1
);
QString
result
=
QString
::
fromLatin1
(
processN
.
readAll
());
result
.
remove
(
' '
);
if
(
!
(
result
.
isEmpty
()
||
result
.
isNull
()
||
result
.
contains
(
'\''
)))
{
list
=
result
.
remove
(
"
\n
"
).
remove
(
"
\r
"
).
split
(
":"
).
at
(
1
).
split
(
","
);
}
QProcess
process
;
process
.
start
(
QString
(
"%1 wallet list"
).
arg
(
m_sCliPath
));
process
.
waitForFinished
(
-
1
);
QString
res
=
QString
::
fromLatin1
(
process
.
readAll
());
QRegularExpression
rx
(
"wallet:
\\
s(.+)
\\
s"
,
QRegularExpression
::
MultilineOption
);
QRegularExpressionMatchIterator
itr
=
rx
.
globalMatch
(
res
);
while
(
itr
.
hasNext
())
{
QRegularExpressionMatch
match
=
itr
.
next
();
QString
walletName
=
match
.
captured
(
1
);
DapWallet
wallet
;
wallet
.
setName
(
walletName
);
auto
begin
=
list
.
begin
();
auto
end
=
list
.
end
();
for
(;
begin
!=
end
;
++
begin
)
{
wallet
.
addNetwork
(
*
begin
);
QProcess
process_token
;
process_token
.
start
(
QString
(
"%1 wallet info -w %2 -net %3"
)
.
arg
(
m_sCliPath
)
.
arg
(
walletName
)
.
arg
(
*
begin
));
process_token
.
waitForFinished
(
-
1
);
QByteArray
result_tokens
=
process_token
.
readAll
();
QRegExp
regex
(
"wallet: (.+)
\\
s+addr:
\\
s+(.+)
\\
s+(balance)|(
\\
d+.
\\
d+)
\\
s
\\
((
\\
d+)
\\
)
\\
s(
\\
w+)"
);
int
pos
=
0
;
DapWalletToken
*
token
{
nullptr
};
while
((
pos
=
regex
.
indexIn
(
result_tokens
,
pos
))
!=
-
1
)
{
if
(
!
regex
.
cap
(
2
).
isEmpty
())
{
wallet
.
addAddress
(
regex
.
cap
(
2
),
*
begin
);
}
else
{
token
=
new
DapWalletToken
();
token
->
setName
(
regex
.
cap
(
6
).
trimmed
());
token
->
setBalance
(
regex
.
cap
(
4
).
toDouble
());
QString
str
=
regex
.
cap
(
5
);
token
->
setEmission
(
regex
.
cap
(
5
).
toULongLong
());
token
->
setNetwork
(
*
begin
);
wallet
.
addToken
(
token
);
}
pos
+=
regex
.
matchedLength
();
}
}
wallets
.
append
(
wallet
);
}
QByteArray
datas
;
QDataStream
out
(
&
datas
,
QIODevice
::
WriteOnly
);
out
<<
wallets
;
return
QJsonValue
::
fromVariant
(
datas
.
toHex
());
}
/// Reply from service.
/// @details Performed on the service side.
/// @return Service reply.
QVariant
DapGetWalletsInfoCommand
::
replyFromService
()
{
DapRpcServiceReply
*
reply
=
static_cast
<
DapRpcServiceReply
*>
(
sender
());
emit
serviceResponded
(
reply
->
response
().
toJsonValue
().
toVariant
().
toByteArray
());
return
reply
->
response
().
toJsonValue
().
toVariant
();
}
This diff is collapsed.
Click to expand it.
handlers/DapGetWalletsInfoCommand.h
0 → 100644
+
38
−
0
View file @
4e3d5ca3
#ifndef DAPGETWALLETSINFOCOMMAND_H
#define DAPGETWALLETSINFOCOMMAND_H
#include
<QProcess>
#include
<QRegExp>
#include
<QRegularExpression>
#include
<QByteArray>
#include
<QDataStream>
#include
<QBuffer>
#include
<QTextCodec>
#include
"DapWallet.h"
#include
"DapAbstractCommand.h"
class
DapGetWalletsInfoCommand
:
public
DapAbstractCommand
{
public:
/// Overloaded constructor.
/// @param asServiceName Service name.
/// @param parent Parent.
/// @details The parent must be either DapRPCSocket or DapRPCLocalServer.
/// @param asCliPath The path to cli nodes.
DapGetWalletsInfoCommand
(
const
QString
&
asServicename
,
QObject
*
parent
=
nullptr
,
const
QString
&
asCliPath
=
QString
());
public
slots
:
/// Send a response to the client.
/// @details Performed on the service side.
/// @param arg1...arg10 Parameters.
/// @return Reply to client.
QVariant
respondToClient
(
const
QVariant
&
arg1
=
QVariant
(),
const
QVariant
&
arg2
=
QVariant
(),
const
QVariant
&
arg3
=
QVariant
(),
const
QVariant
&
arg4
=
QVariant
(),
const
QVariant
&
arg5
=
QVariant
(),
const
QVariant
&
arg6
=
QVariant
(),
const
QVariant
&
arg7
=
QVariant
(),
const
QVariant
&
arg8
=
QVariant
(),
const
QVariant
&
arg9
=
QVariant
(),
const
QVariant
&
arg10
=
QVariant
())
override
;
QVariant
replyFromService
()
override
;
};
#endif // DAPGETWALLETSINFOCOMMAND_H
This diff is collapsed.
Click to expand it.
libdap-qt-ui-chain-wallet.pri
+
2
−
0
View file @
4e3d5ca3
...
@@ -30,6 +30,7 @@ HEADERS += \
...
@@ -30,6 +30,7 @@ HEADERS += \
$$PWD/handlers/DapGetHistoryExecutedCmdCommand.h \
$$PWD/handlers/DapGetHistoryExecutedCmdCommand.h \
$$PWD/handlers/DapGetListNetworksCommand.h \
$$PWD/handlers/DapGetListNetworksCommand.h \
$$PWD/handlers/DapGetListWalletsCommand.h \
$$PWD/handlers/DapGetListWalletsCommand.h \
$$PWD/handlers/DapGetWalletsInfoCommand.h \
$$PWD/handlers/DapGetWalletAddressesCommand.h \
$$PWD/handlers/DapGetWalletAddressesCommand.h \
$$PWD/handlers/DapGetWalletHistoryCommand.h \
$$PWD/handlers/DapGetWalletHistoryCommand.h \
$$PWD/handlers/DapGetWalletInfoCommand.h \
$$PWD/handlers/DapGetWalletInfoCommand.h \
...
@@ -64,6 +65,7 @@ SOURCES += \
...
@@ -64,6 +65,7 @@ SOURCES += \
$$PWD/handlers/DapGetHistoryExecutedCmdCommand.cpp \
$$PWD/handlers/DapGetHistoryExecutedCmdCommand.cpp \
$$PWD/handlers/DapGetListNetworksCommand.cpp \
$$PWD/handlers/DapGetListNetworksCommand.cpp \
$$PWD/handlers/DapGetListWalletsCommand.cpp \
$$PWD/handlers/DapGetListWalletsCommand.cpp \
$$PWD/handlers/DapGetWalletsInfoCommand.cpp \
$$PWD/handlers/DapGetWalletAddressesCommand.cpp \
$$PWD/handlers/DapGetWalletAddressesCommand.cpp \
$$PWD/handlers/DapGetWalletHistoryCommand.cpp \
$$PWD/handlers/DapGetWalletHistoryCommand.cpp \
$$PWD/handlers/DapGetWalletInfoCommand.cpp \
$$PWD/handlers/DapGetWalletInfoCommand.cpp \
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment