Browse Source

Updated for Peercoin

peercoin
Intel 11 years ago
parent
commit
4931afd7ed
  1. 2
      src/server/poolserver/NetworkMgr/NetworkMgr.cpp
  2. 6
      src/server/shared/Bitcoin/Bitcoin.h
  3. 1
      src/server/shared/Bitcoin/Block.h
  4. 6
      src/server/shared/Bitcoin/Serialization.cpp
  5. 1
      src/server/shared/Bitcoin/Transaction.h

2
src/server/poolserver/NetworkMgr/NetworkMgr.cpp

@ -61,7 +61,7 @@ void NetworkMgr::UpdateBlockTemplate() @@ -61,7 +61,7 @@ void NetworkMgr::UpdateBlockTemplate()
// Add coinbase tx
BinaryData pubkey = Util::ASCIIToBin(sConfig.Get<std::string>("MiningAddress"));
block->tx.push_back(Bitcoin::CreateCoinbaseTX(_blockHeight, pubkey, response["coinbasevalue"].GetInt()));
block->tx.push_back(Bitcoin::CreateCoinbaseTX(_blockHeight, pubkey, response["coinbasevalue"].GetInt(), Util::ASCIIToBin("D7PoolBeta")));
// Add other transactions
JSON trans = response["transactions"];

6
src/server/shared/Bitcoin/Bitcoin.h

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
#include "VarInt.h"
#include "Script.h"
#include "BigNum.h"
#include "Util.h"
#include <gmpxx.h>
namespace Bitcoin
@ -31,12 +32,12 @@ namespace Bitcoin @@ -31,12 +32,12 @@ namespace Bitcoin
return BigInt(bits & 0xFFFFFF) * BigInt(power);
}
inline Transaction CreateCoinbaseTX(uint32 blockHeight, BinaryData pubkey, int64 value)
inline Transaction CreateCoinbaseTX(uint32 blockHeight, BinaryData pubkey, int64 value, BinaryData extras)
{
// Extranonce placeholder
BinaryData extranonce_ph(8, 0);
ByteBuffer scriptsig;
scriptsig << blockHeight << extranonce_ph;
scriptsig << blockHeight << extranonce_ph << extras;
Bitcoin::OutPoint outpoint;
outpoint.hash.resize(32, 0);
@ -53,6 +54,7 @@ namespace Bitcoin @@ -53,6 +54,7 @@ namespace Bitcoin
Transaction tx;
tx.version = 1;
tx.time = Util:Date();
tx.in.push_back(txin);
tx.out.push_back(txout);
tx.lockTime = 0;

1
src/server/shared/Bitcoin/Block.h

@ -18,6 +18,7 @@ namespace Bitcoin @@ -18,6 +18,7 @@ namespace Bitcoin
uint32 time;
uint32 bits;
uint32 nonce;
BinaryData signature;
};
class Block : public BlockHeader

6
src/server/shared/Bitcoin/Serialization.cpp

@ -100,6 +100,7 @@ ByteBuffer& Bitcoin::operator>>(ByteBuffer& a, TxOut& b) @@ -100,6 +100,7 @@ ByteBuffer& Bitcoin::operator>>(ByteBuffer& a, TxOut& b)
ByteBuffer& Bitcoin::operator<<(ByteBuffer& a, Transaction& b)
{
a << b.version;
a << b.time;
// Inputs
VarInt insize(b.in.size());
@ -120,6 +121,7 @@ ByteBuffer& Bitcoin::operator<<(ByteBuffer& a, Transaction& b) @@ -120,6 +121,7 @@ ByteBuffer& Bitcoin::operator<<(ByteBuffer& a, Transaction& b)
ByteBuffer& Bitcoin::operator>>(ByteBuffer& a, Transaction& b)
{
a >> b.version;
a >> b.time;
// Inputs
VarInt insize;
@ -158,6 +160,8 @@ ByteBuffer& Bitcoin::operator<<(ByteBuffer& a, Block& b) @@ -158,6 +160,8 @@ ByteBuffer& Bitcoin::operator<<(ByteBuffer& a, Block& b)
for (uint64 i = 0; i < txcount; ++i)
a << b.tx[i];
a << b.signature;
return a;
}
ByteBuffer& Bitcoin::operator>>(ByteBuffer& a, Block& b)
@ -176,5 +180,7 @@ ByteBuffer& Bitcoin::operator>>(ByteBuffer& a, Block& b) @@ -176,5 +180,7 @@ ByteBuffer& Bitcoin::operator>>(ByteBuffer& a, Block& b)
for (uint64 i = 0; i < txcount; ++i)
a >> b.tx[i];
a >> b.signature;
return a;
}

1
src/server/shared/Bitcoin/Transaction.h

@ -47,6 +47,7 @@ namespace Bitcoin @@ -47,6 +47,7 @@ namespace Bitcoin
{
public:
uint32 version;
uint32 time;
std::vector<TxIn> in;
std::vector<TxOut> out;
uint32 lockTime;

Loading…
Cancel
Save