mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 21:13:31 +02:00
initial rev of SignedWalletTransaction that creates a message
This commit is contained in:
parent
29504325d0
commit
74a107f9f4
5 changed files with 90 additions and 1 deletions
interface/src
libraries/networking/src
|
@ -74,6 +74,7 @@
|
|||
#include "devices/OculusManager.h"
|
||||
#include "devices/TV3DManager.h"
|
||||
#include "renderer/ProgramObject.h"
|
||||
#include "SignedWalletTransaction.h"
|
||||
|
||||
#include "scripting/AccountScriptingInterface.h"
|
||||
#include "scripting/AudioDeviceScriptingInterface.h"
|
||||
|
@ -405,6 +406,12 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
MIDIManager& midiManagerInstance = MIDIManager::getInstance();
|
||||
midiManagerInstance.openDefaultPort();
|
||||
#endif
|
||||
|
||||
|
||||
QUuid destinationWallet = QUuid::createUuid();
|
||||
|
||||
SignedWalletTransaction testTransaction(destinationWallet, 1000, QDateTime::currentDateTime().toTime_t(), 3600);
|
||||
qDebug() << "Message digest is" << testTransaction.hexMessage();
|
||||
}
|
||||
|
||||
Application::~Application() {
|
||||
|
|
51
interface/src/SignedWalletTransaction.cpp
Normal file
51
interface/src/SignedWalletTransaction.cpp
Normal file
|
@ -0,0 +1,51 @@
|
|||
//
|
||||
// SignedWalletTransaction.cpp
|
||||
// interface/src
|
||||
//
|
||||
// Created by Stephen Birarda on 2014-07-11.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <QtCore/QCryptographicHash>
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QFile>
|
||||
|
||||
#include "SignedWalletTransaction.h"
|
||||
|
||||
SignedWalletTransaction::SignedWalletTransaction(const QUuid& destinationUUID, qint64 amount,
|
||||
qint64 messageTimestamp, qint64 expiryDelta) :
|
||||
WalletTransaction(destinationUUID, amount),
|
||||
_messageTimestamp(messageTimestamp),
|
||||
_expiryDelta(expiryDelta)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QByteArray SignedWalletTransaction::hexMessage() {
|
||||
// build the message using the components of this transaction
|
||||
|
||||
// UUID, source UUID, destination UUID, message timestamp, expiry delta, amount
|
||||
QByteArray messageBinary;
|
||||
|
||||
messageBinary.append(_uuid.toRfc4122());
|
||||
|
||||
messageBinary.append(reinterpret_cast<const char*>(&_messageTimestamp), sizeof(_messageTimestamp));
|
||||
messageBinary.append(reinterpret_cast<const char*>(&_expiryDelta), sizeof(_expiryDelta));
|
||||
|
||||
QUuid sourceUUID = QUuid::createUuid();
|
||||
qDebug() << "The faked source UUID is" << sourceUUID;
|
||||
messageBinary.append(sourceUUID.toRfc4122());
|
||||
|
||||
messageBinary.append(_destinationUUID.toRfc4122());
|
||||
|
||||
messageBinary.append(reinterpret_cast<const char*>(&_amount), sizeof(_amount));
|
||||
|
||||
return messageBinary.toHex();
|
||||
}
|
||||
|
||||
QByteArray SignedWalletTransaction::messageDigest() {
|
||||
return QCryptographicHash::hash(hexMessage(), QCryptographicHash::Sha256);
|
||||
}
|
31
interface/src/SignedWalletTransaction.h
Normal file
31
interface/src/SignedWalletTransaction.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
//
|
||||
// SignedWalletTransaction.h
|
||||
// interfac/src
|
||||
//
|
||||
// Created by Stephen Birarda on 2014-07-11.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_SignedWalletTransaction_h
|
||||
#define hifi_SignedWalletTransaction_h
|
||||
|
||||
#include <WalletTransaction.h>
|
||||
|
||||
class SignedWalletTransaction : public WalletTransaction {
|
||||
Q_OBJECT
|
||||
public:
|
||||
SignedWalletTransaction(const QUuid& destinationUUID, qint64 amount, qint64 messageTimestamp, qint64 expiryDelta);
|
||||
|
||||
QByteArray hexMessage();
|
||||
QByteArray messageDigest();
|
||||
QByteArray signedMessageDigest();
|
||||
|
||||
private:
|
||||
qint64 _messageTimestamp;
|
||||
qint64 _expiryDelta;
|
||||
};
|
||||
|
||||
#endif // hifi_SignedWalletTransaction_h
|
|
@ -36,7 +36,7 @@ public:
|
|||
QJsonDocument postJson();
|
||||
QJsonObject toJson();
|
||||
void loadFromJson(const QJsonObject& jsonObject);
|
||||
private:
|
||||
protected:
|
||||
QUuid _uuid;
|
||||
QUuid _destinationUUID;
|
||||
qint64 _amount;
|
Loading…
Reference in a new issue