From ce4336894a1fed5172dda18071334fa200023b75 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 31 Jul 2014 09:26:18 -0700 Subject: [PATCH] actually send signed transaction from PaymentManager --- interface/src/PaymentManager.cpp | 15 ++++++++++++++- interface/src/SignedWalletTransaction.h | 2 ++ libraries/networking/src/PacketHeaders.h | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/interface/src/PaymentManager.cpp b/interface/src/PaymentManager.cpp index b8af43ec67..84f5e96fc9 100644 --- a/interface/src/PaymentManager.cpp +++ b/interface/src/PaymentManager.cpp @@ -13,6 +13,9 @@ #include #include +#include +#include + #include "SignedWalletTransaction.h" #include "PaymentManager.h" @@ -23,7 +26,6 @@ PaymentManager& PaymentManager::getInstance() { } void PaymentManager::sendSignedPayment(qint64 satoshiAmount, const QUuid& nodeUUID, const QUuid& destinationWalletUUID) { - qDebug() << "Paying" << satoshiAmount << "satoshis to" << destinationWalletUUID << "via" << nodeUUID; // setup a signed wallet transaction const qint64 DEFAULT_TRANSACTION_EXPIRY_SECONDS = 60; @@ -32,4 +34,15 @@ void PaymentManager::sendSignedPayment(qint64 satoshiAmount, const QUuid& nodeUU currentTimestamp, DEFAULT_TRANSACTION_EXPIRY_SECONDS); // send the signed transaction to the redeeming node + QByteArray transactionByteArray = byteArrayWithPopulatedHeader(PacketTypeSignedTransactionPayment); + + // append the binary message and the signed message digest + transactionByteArray.append(newTransaction.binaryMessage()); + transactionByteArray.append(newTransaction.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)); } \ No newline at end of file diff --git a/interface/src/SignedWalletTransaction.h b/interface/src/SignedWalletTransaction.h index 6bc66a535e..b3b1620dac 100644 --- a/interface/src/SignedWalletTransaction.h +++ b/interface/src/SignedWalletTransaction.h @@ -14,6 +14,8 @@ #include +const int NUM_BYTES_SIGNED_TRANSACTION_MESSAGE = 72; + class SignedWalletTransaction : public WalletTransaction { Q_OBJECT public: diff --git a/libraries/networking/src/PacketHeaders.h b/libraries/networking/src/PacketHeaders.h index 83350a32d1..436c34e6eb 100644 --- a/libraries/networking/src/PacketHeaders.h +++ b/libraries/networking/src/PacketHeaders.h @@ -70,6 +70,7 @@ enum PacketType { PacketTypeVoxelEditNack, PacketTypeParticleEditNack, PacketTypeModelEditNack, + PacketTypeSignedTransactionPayment }; typedef char PacketVersion;