mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 11:17:34 +02:00
Merge pull request #3231 from birarda/domain-server-auth
add some error messages to PaymentManager
This commit is contained in:
commit
c4751d7dd7
1 changed files with 33 additions and 17 deletions
|
@ -13,6 +13,7 @@
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
#include <QtCore/QUuid>
|
#include <QtCore/QUuid>
|
||||||
|
|
||||||
|
#include <Menu.h>
|
||||||
#include <NodeList.h>
|
#include <NodeList.h>
|
||||||
#include <PacketHeaders.h>
|
#include <PacketHeaders.h>
|
||||||
|
|
||||||
|
@ -27,22 +28,37 @@ PaymentManager& PaymentManager::getInstance() {
|
||||||
|
|
||||||
void PaymentManager::sendSignedPayment(qint64 satoshiAmount, const QUuid& nodeUUID, const QUuid& destinationWalletUUID) {
|
void PaymentManager::sendSignedPayment(qint64 satoshiAmount, const QUuid& nodeUUID, const QUuid& destinationWalletUUID) {
|
||||||
|
|
||||||
// setup a signed wallet transaction
|
QByteArray walletPrivateKeyByteArray = Menu::getInstance()->getWalletPrivateKey();
|
||||||
const qint64 DEFAULT_TRANSACTION_EXPIRY_SECONDS = 60;
|
|
||||||
qint64 currentTimestamp = QDateTime::currentDateTimeUtc().toTime_t();
|
|
||||||
SignedWalletTransaction newTransaction(destinationWalletUUID, satoshiAmount,
|
|
||||||
currentTimestamp, DEFAULT_TRANSACTION_EXPIRY_SECONDS);
|
|
||||||
|
|
||||||
// send the signed transaction to the redeeming node
|
if (!walletPrivateKeyByteArray.isEmpty()) {
|
||||||
QByteArray transactionByteArray = byteArrayWithPopulatedHeader(PacketTypeSignedTransactionPayment);
|
// setup a signed wallet transaction
|
||||||
|
const qint64 DEFAULT_TRANSACTION_EXPIRY_SECONDS = 60;
|
||||||
// append the binary message and the signed message digest
|
qint64 currentTimestamp = QDateTime::currentDateTimeUtc().toTime_t();
|
||||||
transactionByteArray.append(newTransaction.binaryMessage());
|
SignedWalletTransaction newTransaction(destinationWalletUUID, satoshiAmount,
|
||||||
transactionByteArray.append(newTransaction.signedMessageDigest());
|
currentTimestamp, DEFAULT_TRANSACTION_EXPIRY_SECONDS);
|
||||||
|
|
||||||
qDebug() << "Paying" << satoshiAmount << "satoshis to" << destinationWalletUUID << "via" << nodeUUID;
|
// send the signed transaction to the redeeming node
|
||||||
|
QByteArray transactionByteArray = byteArrayWithPopulatedHeader(PacketTypeSignedTransactionPayment);
|
||||||
// use the NodeList to send that to the right node
|
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
// append the binary message and the signed message digest
|
||||||
nodeList->writeDatagram(transactionByteArray, nodeList->nodeWithUUID(nodeUUID));
|
transactionByteArray.append(newTransaction.binaryMessage());
|
||||||
|
QByteArray signedMessageDigest = newTransaction.signedMessageDigest();
|
||||||
|
|
||||||
|
if (!signedMessageDigest.isEmpty()) {
|
||||||
|
transactionByteArray.append(signedMessageDigest);
|
||||||
|
|
||||||
|
qDebug() << "Paying" << satoshiAmount << "satoshis to" << destinationWalletUUID << "via" << nodeUUID;
|
||||||
|
|
||||||
|
// use the NodeList to send that to the right node
|
||||||
|
NodeList* nodeList = NodeList::getInstance();
|
||||||
|
nodeList->writeDatagram(transactionByteArray, nodeList->nodeWithUUID(nodeUUID));
|
||||||
|
} else {
|
||||||
|
qDebug() << "Payment of" << satoshiAmount << "satoshis to" << destinationWalletUUID << "via" << nodeUUID <<
|
||||||
|
"cannot be sent because there was an error signing the transaction.";
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
qDebug() << "Payment of" << satoshiAmount << "satoshis to" << destinationWalletUUID << "via" << nodeUUID <<
|
||||||
|
"cannot be sent because there is no stored wallet private key.";
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue