mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Merge branch 'master' into bootstrap
This commit is contained in:
21
src/Peer.cpp
21
src/Peer.cpp
@@ -712,6 +712,27 @@ void Peer::recvLedger(newcoin::TMLedgerData& packet)
|
|||||||
punishPeer(PP_UNWANTED_DATA);
|
punishPeer(PP_UNWANTED_DATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<unsigned char> Peer::getSessionCookie()
|
||||||
|
{
|
||||||
|
// get session information we can sign
|
||||||
|
// (both sides get the same information, neither side controls it)
|
||||||
|
SSL* ssl = mSocketSsl.native_handle();
|
||||||
|
if (!ssl) throw std::runtime_error("No underlying connection");
|
||||||
|
|
||||||
|
// Get both finished messages
|
||||||
|
unsigned char s1[1024], s2[1024];
|
||||||
|
int l1 = SSL_get_finished(ssl, s1, 1024);
|
||||||
|
int l2 = SSL_get_finished(ssl, s2, 1024);
|
||||||
|
if ((l1 < 16) || (l2 < 16)) throw std::runtime_error("Connection setup not complete");
|
||||||
|
|
||||||
|
// Hash them and XOR the results
|
||||||
|
unsigned char sha1[32], sha2[32];
|
||||||
|
SHA512(s1, l1, sha1);
|
||||||
|
SHA512(s2, l2, sha2);
|
||||||
|
for(int i=0; i<32; i++) sha1[i]^=sha2[i];
|
||||||
|
return std::vector<unsigned char>(sha1, sha1+33);
|
||||||
|
}
|
||||||
|
|
||||||
void Peer::sendHello()
|
void Peer::sendHello()
|
||||||
{
|
{
|
||||||
// XXX Start timer for hello required by.
|
// XXX Start timer for hello required by.
|
||||||
|
|||||||
@@ -81,6 +81,8 @@ protected:
|
|||||||
void recvGetLedger(newcoin::TMGetLedger& packet);
|
void recvGetLedger(newcoin::TMGetLedger& packet);
|
||||||
void recvLedger(newcoin::TMLedgerData& packet);
|
void recvLedger(newcoin::TMLedgerData& packet);
|
||||||
|
|
||||||
|
std::vector<unsigned char> getSessionCookie();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef boost::shared_ptr<Peer> pointer;
|
typedef boost::shared_ptr<Peer> pointer;
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include "SerializedLedger.h"
|
#include "SerializedLedger.h"
|
||||||
|
|
||||||
SerializedLedgerEntry::SerializedLedgerEntry(SerializerIterator& sit, const uint256& index)
|
SerializedLedgerEntry::SerializedLedgerEntry(SerializerIterator& sit, const uint256& index)
|
||||||
: STObject("LedgerEntry"), mIndex(index)
|
: SerializedType("LedgerEntry"), mIndex(index)
|
||||||
{
|
{
|
||||||
uint16 type = sit.get16();
|
uint16 type = sit.get16();
|
||||||
mFormat = getLgrFormat(static_cast<LedgerEntryType>(type));
|
mFormat = getLgrFormat(static_cast<LedgerEntryType>(type));
|
||||||
@@ -13,7 +13,7 @@ SerializedLedgerEntry::SerializedLedgerEntry(SerializerIterator& sit, const uint
|
|||||||
}
|
}
|
||||||
|
|
||||||
SerializedLedgerEntry::SerializedLedgerEntry(const Serializer& s, const uint256& index)
|
SerializedLedgerEntry::SerializedLedgerEntry(const Serializer& s, const uint256& index)
|
||||||
: STObject("LedgerEntry"), mIndex(index)
|
: SerializedType("LedgerEntry"), mIndex(index)
|
||||||
{
|
{
|
||||||
SerializerIterator sit(s);
|
SerializerIterator sit(s);
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ SerializedLedgerEntry::SerializedLedgerEntry(const Serializer& s, const uint256&
|
|||||||
mObject = STObject(mFormat->elements, sit);
|
mObject = STObject(mFormat->elements, sit);
|
||||||
}
|
}
|
||||||
|
|
||||||
SerializedLedgerEntry::SerializedLedgerEntry(LedgerEntryType type) : STObject("LedgerEntry"), mType(type)
|
SerializedLedgerEntry::SerializedLedgerEntry(LedgerEntryType type) : SerializedType("LedgerEntry"), mType(type)
|
||||||
{
|
{
|
||||||
mFormat = getLgrFormat(type);
|
mFormat = getLgrFormat(type);
|
||||||
if (mFormat == NULL) throw std::runtime_error("invalid ledger entry type");
|
if (mFormat == NULL) throw std::runtime_error("invalid ledger entry type");
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include "LedgerFormats.h"
|
#include "LedgerFormats.h"
|
||||||
#include "NewcoinAddress.h"
|
#include "NewcoinAddress.h"
|
||||||
|
|
||||||
class SerializedLedgerEntry : public STObject
|
class SerializedLedgerEntry : public SerializedType
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef boost::shared_ptr<SerializedLedgerEntry> pointer;
|
typedef boost::shared_ptr<SerializedLedgerEntry> pointer;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
#include "TransactionFormats.h"
|
#include "TransactionFormats.h"
|
||||||
#include "NewcoinAddress.h"
|
#include "NewcoinAddress.h"
|
||||||
|
|
||||||
class SerializedTransaction : public STObject
|
class SerializedTransaction : public SerializedType
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef boost::shared_ptr<SerializedTransaction> pointer;
|
typedef boost::shared_ptr<SerializedTransaction> pointer;
|
||||||
|
|||||||
@@ -125,8 +125,8 @@ Transaction::Transaction(const NewcoinAddress& fromID, const NewcoinAddress& toI
|
|||||||
mTransaction->makeITFieldPresent(sfSourceTag);
|
mTransaction->makeITFieldPresent(sfSourceTag);
|
||||||
mTransaction->setITFieldU32(sfSourceTag, ident);
|
mTransaction->setITFieldU32(sfSourceTag, ident);
|
||||||
}
|
}
|
||||||
mTransaction->setValueFieldU64(sfAmount, amount);
|
mTransaction->setITFieldU64(sfAmount, amount);
|
||||||
mTransaction->setValueFieldAccount(sfDestination, toID.getAccountID());
|
mTransaction->setITFieldAccount(sfDestination, toID.getAccountID());
|
||||||
updateID();
|
updateID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user