mirror of
https://github.com/GOSTSec/poolserver
synced 2025-01-15 01:00:10 +00:00
rename Bitcoin to Gostcoin
This commit is contained in:
parent
e7ccdfa9db
commit
1f12b4f30d
@ -28,7 +28,7 @@ include_directories(
|
|||||||
${CMAKE_SOURCE_DIR}/src/server/shared/Logging
|
${CMAKE_SOURCE_DIR}/src/server/shared/Logging
|
||||||
${CMAKE_SOURCE_DIR}/src/server/shared/JSON
|
${CMAKE_SOURCE_DIR}/src/server/shared/JSON
|
||||||
${CMAKE_SOURCE_DIR}/src/server/shared/JSONRPC
|
${CMAKE_SOURCE_DIR}/src/server/shared/JSONRPC
|
||||||
${CMAKE_SOURCE_DIR}/src/server/shared/Bitcoin
|
${CMAKE_SOURCE_DIR}/src/server/shared/Gostcoin
|
||||||
${Boost_INCLUDE_DIR}
|
${Boost_INCLUDE_DIR}
|
||||||
${MYSQL_INCLUDE_DIR}
|
${MYSQL_INCLUDE_DIR}
|
||||||
${GMP_INCLUDE_DIR}
|
${GMP_INCLUDE_DIR}
|
||||||
|
@ -15,20 +15,20 @@ NetworkMgr::~NetworkMgr()
|
|||||||
delete _cons[i];
|
delete _cons[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bitcoin daemon connection
|
// Gostcoin daemon connection
|
||||||
void NetworkMgr::Connect(JSONRPCConnectionInfo coninfo)
|
void NetworkMgr::Connect(JSONRPCConnectionInfo coninfo)
|
||||||
{
|
{
|
||||||
JSONRPC* bitcoinrpc = new JSONRPC();
|
JSONRPC* gostcoinrpc = new JSONRPC();
|
||||||
bitcoinrpc->Connect(coninfo);
|
gostcoinrpc->Connect(coninfo);
|
||||||
|
|
||||||
JSON response = bitcoinrpc->Query("getinfo");
|
JSON response = gostcoinrpc->Query("getinfo");
|
||||||
|
|
||||||
if (response["error"].GetType() != JSON_NULL)
|
if (response["error"].GetType() != JSON_NULL)
|
||||||
throw Exception(Util::FS("Failed to get response from bitcoin rpc: %s", response["error"].GetString().c_str()));
|
throw Exception(Util::FS("Failed to get response from gostcoin rpc: %s", response["error"].GetString().c_str()));
|
||||||
|
|
||||||
sLog.Info(LOG_SERVER, "Connected to Bitcoin RPC at %s:%s", coninfo.Host.c_str(), coninfo.Port.c_str());
|
sLog.Info(LOG_SERVER, "Connected to Gostcoin RPC at %s:%s", coninfo.Host.c_str(), coninfo.Port.c_str());
|
||||||
|
|
||||||
_cons.push_back(bitcoinrpc);
|
_cons.push_back(gostcoinrpc);
|
||||||
|
|
||||||
// Fetch block height on first connection
|
// Fetch block height on first connection
|
||||||
if (_cons.size() == 1)
|
if (_cons.size() == 1)
|
||||||
@ -50,7 +50,7 @@ void NetworkMgr::UpdateBlockTemplate()
|
|||||||
if (response["height"].GetInt() < _blockHeight)
|
if (response["height"].GetInt() < _blockHeight)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Bitcoin::BlockPtr block = Bitcoin::BlockPtr(new Bitcoin::Block());
|
Gostcoin::BlockPtr block = Gostcoin::BlockPtr(new Gostcoin::Block());
|
||||||
|
|
||||||
block->version = response["version"].GetInt();
|
block->version = response["version"].GetInt();
|
||||||
block->prevBlockHash = Util::Reverse(Util::ASCIIToBin(response["previousblockhash"].GetString()));
|
block->prevBlockHash = Util::Reverse(Util::ASCIIToBin(response["previousblockhash"].GetString()));
|
||||||
@ -61,13 +61,13 @@ void NetworkMgr::UpdateBlockTemplate()
|
|||||||
|
|
||||||
// Add coinbase tx
|
// Add coinbase tx
|
||||||
BinaryData pubkey = Util::ASCIIToBin(sConfig.Get<std::string>("MiningAddress"));
|
BinaryData pubkey = Util::ASCIIToBin(sConfig.Get<std::string>("MiningAddress"));
|
||||||
block->tx.push_back(Bitcoin::CreateCoinbaseTX(_blockHeight, pubkey, response["coinbasevalue"].GetInt()));
|
block->tx.push_back(Gostcoin::CreateCoinbaseTX(_blockHeight, pubkey, response["coinbasevalue"].GetInt()));
|
||||||
|
|
||||||
// Add other transactions
|
// Add other transactions
|
||||||
JSON trans = response["transactions"];
|
JSON trans = response["transactions"];
|
||||||
for (uint64 tidx = 0; tidx < trans.Size(); ++tidx) {
|
for (uint64 tidx = 0; tidx < trans.Size(); ++tidx) {
|
||||||
ByteBuffer txbuf(Util::ASCIIToBin(trans[tidx]["data"].GetString()));
|
ByteBuffer txbuf(Util::ASCIIToBin(trans[tidx]["data"].GetString()));
|
||||||
Bitcoin::Transaction tx;
|
Gostcoin::Transaction tx;
|
||||||
txbuf >> tx;
|
txbuf >> tx;
|
||||||
block->tx.push_back(tx);
|
block->tx.push_back(tx);
|
||||||
}
|
}
|
||||||
@ -89,7 +89,7 @@ void NetworkMgr::UpdateBlockTemplate()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Submit new block
|
// Submit new block
|
||||||
bool NetworkMgr::SubmitBlock(Bitcoin::Block block)
|
bool NetworkMgr::SubmitBlock(Gostcoin::Block block)
|
||||||
{
|
{
|
||||||
// Serialize block
|
// Serialize block
|
||||||
ByteBuffer blockbuf;
|
ByteBuffer blockbuf;
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
#ifndef NETWORKMGR_H_
|
#ifndef NETWORKMGR_H_
|
||||||
#define NETWORKMGR_H_
|
#define NETWORKMGR_H_
|
||||||
|
|
||||||
// Provides high level interaction with bitcoin daemon
|
// Provides high level interaction with gostcoin daemon
|
||||||
|
|
||||||
#include "JSONRPC.h"
|
#include "JSONRPC.h"
|
||||||
#include "Bitcoin.h"
|
#include "Gostcoin.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
using namespace boost;
|
using namespace boost;
|
||||||
|
|
||||||
typedef boost::function<void (Bitcoin::BlockPtr /*blockTmpl*/, bool /*newBlock*/)> FBlockNotify;
|
typedef boost::function<void (Gostcoin::BlockPtr /*blockTmpl*/, bool /*newBlock*/)> FBlockNotify;
|
||||||
|
|
||||||
class NetworkMgr
|
class NetworkMgr
|
||||||
{
|
{
|
||||||
@ -36,14 +36,14 @@ public:
|
|||||||
NetworkMgr(asio::io_service& io_service);
|
NetworkMgr(asio::io_service& io_service);
|
||||||
~NetworkMgr();
|
~NetworkMgr();
|
||||||
|
|
||||||
// Bitcoin daemon connection
|
// Gostcoin daemon connection
|
||||||
void Connect(JSONRPCConnectionInfo coninfo);
|
void Connect(JSONRPCConnectionInfo coninfo);
|
||||||
|
|
||||||
// Get new block template
|
// Get new block template
|
||||||
void UpdateBlockTemplate();
|
void UpdateBlockTemplate();
|
||||||
|
|
||||||
// Submit new block
|
// Submit new block
|
||||||
bool SubmitBlock(Bitcoin::Block block);
|
bool SubmitBlock(Gostcoin::Block block);
|
||||||
|
|
||||||
// Checking for blocks
|
// Checking for blocks
|
||||||
void BlockCheck();
|
void BlockCheck();
|
||||||
@ -70,11 +70,11 @@ private:
|
|||||||
boost::mutex _mtxBlockCheck;
|
boost::mutex _mtxBlockCheck;
|
||||||
uint32 _blockHeight;
|
uint32 _blockHeight;
|
||||||
|
|
||||||
// Connections to bitcoin rpc
|
// Connections to gostcoin rpc
|
||||||
std::vector<JSONRPC*> _cons;
|
std::vector<JSONRPC*> _cons;
|
||||||
|
|
||||||
// Current block template
|
// Current block template
|
||||||
Bitcoin::BlockPtr _curBlockTmpl;
|
Gostcoin::BlockPtr _curBlockTmpl;
|
||||||
boost::mutex _mtxBlockTmpl;
|
boost::mutex _mtxBlockTmpl;
|
||||||
|
|
||||||
// ASIO
|
// ASIO
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include "Stratum/Server.h"
|
#include "Stratum/Server.h"
|
||||||
#include "ServerDatabaseEnv.h"
|
#include "ServerDatabaseEnv.h"
|
||||||
#include "Crypto.h"
|
#include "Crypto.h"
|
||||||
#include "Bitcoin.h"
|
#include "Gostcoin.h"
|
||||||
#include "DataMgr.h"
|
#include "DataMgr.h"
|
||||||
#include "NetworkMgr.h"
|
#include "NetworkMgr.h"
|
||||||
#include "Exception.h"
|
#include "Exception.h"
|
||||||
|
@ -199,14 +199,14 @@ namespace Stratum
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Copy block we are working on
|
// Copy block we are working on
|
||||||
Bitcoin::Block block = *job->block;
|
Gostcoin::Block block = *job->block;
|
||||||
|
|
||||||
// Start assembling the block
|
// Start assembling the block
|
||||||
timebuf >> block.time;
|
timebuf >> block.time;
|
||||||
noncebuf >> block.nonce;
|
noncebuf >> block.nonce;
|
||||||
|
|
||||||
// Assemble coinbase
|
// Assemble coinbase
|
||||||
Bitcoin::Transaction coinbasetx;
|
Gostcoin::Transaction coinbasetx;
|
||||||
ByteBuffer coinbasebuf;
|
ByteBuffer coinbasebuf;
|
||||||
coinbasebuf << job->coinbase1 << _extranonce << extranonce2 << job->coinbase2;
|
coinbasebuf << job->coinbase1 << _extranonce << extranonce2 << job->coinbase2;
|
||||||
coinbasebuf >> coinbasetx;
|
coinbasebuf >> coinbasetx;
|
||||||
@ -335,8 +335,8 @@ namespace Stratum
|
|||||||
Job* job = new Job();
|
Job* job = new Job();
|
||||||
job->block = _server->GetWork();
|
job->block = _server->GetWork();
|
||||||
job->diff = _diff;
|
job->diff = _diff;
|
||||||
job->jobTarget = Bitcoin::DiffToTarget(job->diff);
|
job->jobTarget = Gostcoin::DiffToTarget(job->diff);
|
||||||
job->blockTarget = Bitcoin::TargetFromBits(job->block->bits);
|
job->blockTarget = Gostcoin::TargetFromBits(job->block->bits);
|
||||||
|
|
||||||
// Serialize transaction
|
// Serialize transaction
|
||||||
ByteBuffer coinbasebuf;
|
ByteBuffer coinbasebuf;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef STRATUM_JOB_H_
|
#ifndef STRATUM_JOB_H_
|
||||||
#define STRATUM_JOB_H_
|
#define STRATUM_JOB_H_
|
||||||
|
|
||||||
#include "Bitcoin.h"
|
#include "Gostcoin.h"
|
||||||
#include "Crypto.h"
|
#include "Crypto.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include "BigNum.h"
|
#include "BigNum.h"
|
||||||
@ -14,7 +14,7 @@ namespace Stratum
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
uint64 diff;
|
uint64 diff;
|
||||||
Bitcoin::BlockPtr block;
|
Gostcoin::BlockPtr block;
|
||||||
BinaryData coinbase1;
|
BinaryData coinbase1;
|
||||||
BinaryData coinbase2;
|
BinaryData coinbase2;
|
||||||
std::set<uint64> shares;
|
std::set<uint64> shares;
|
||||||
|
@ -30,7 +30,7 @@ namespace Stratum
|
|||||||
_io_service.post(boost::bind(&Client::SendJob, (*it), resetWork));
|
_io_service.post(boost::bind(&Client::SendJob, (*it), resetWork));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Server::SubmitBlock(Bitcoin::Block block)
|
bool Server::SubmitBlock(Gostcoin::Block block)
|
||||||
{
|
{
|
||||||
return NetworkMgr::Instance()->SubmitBlock(block);
|
return NetworkMgr::Instance()->SubmitBlock(block);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "JSON.h"
|
#include "JSON.h"
|
||||||
#include "JSONRPC.h"
|
#include "JSONRPC.h"
|
||||||
#include "Bitcoin.h"
|
#include "Gostcoin.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include "ByteBuffer.h"
|
#include "ByteBuffer.h"
|
||||||
#include "NetworkMgr.h"
|
#include "NetworkMgr.h"
|
||||||
@ -76,14 +76,14 @@ namespace Stratum
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Returns current work
|
// Returns current work
|
||||||
Bitcoin::BlockPtr GetWork()
|
Gostcoin::BlockPtr GetWork()
|
||||||
{
|
{
|
||||||
boost::lock_guard<boost::mutex> guard(_mtxCurrentWork);
|
boost::lock_guard<boost::mutex> guard(_mtxCurrentWork);
|
||||||
return _currentWork;
|
return _currentWork;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Block template update event
|
// Block template update event
|
||||||
void BlockNotify(Bitcoin::BlockPtr block, bool newBlock)
|
void BlockNotify(Gostcoin::BlockPtr block, bool newBlock)
|
||||||
{
|
{
|
||||||
sLog.Debug(LOG_STRATUM, "Received block template update");
|
sLog.Debug(LOG_STRATUM, "Received block template update");
|
||||||
_mtxCurrentWork.lock();
|
_mtxCurrentWork.lock();
|
||||||
@ -95,8 +95,8 @@ namespace Stratum
|
|||||||
// Resets work for all clients
|
// Resets work for all clients
|
||||||
void SendBlockTmpl(bool resetWork);
|
void SendBlockTmpl(bool resetWork);
|
||||||
|
|
||||||
// Submits block to bitcoind
|
// Submits block to gostcoind
|
||||||
bool SubmitBlock(Bitcoin::Block block);
|
bool SubmitBlock(Gostcoin::Block block);
|
||||||
|
|
||||||
// Disconnects client
|
// Disconnects client
|
||||||
void Disconnect(ClientPtr client)
|
void Disconnect(ClientPtr client)
|
||||||
@ -173,7 +173,7 @@ namespace Stratum
|
|||||||
boost::mutex _mtxBans;
|
boost::mutex _mtxBans;
|
||||||
|
|
||||||
// Work
|
// Work
|
||||||
Bitcoin::BlockPtr _currentWork;
|
Gostcoin::BlockPtr _currentWork;
|
||||||
boost::mutex _mtxCurrentWork;
|
boost::mutex _mtxCurrentWork;
|
||||||
uint32 _extranonce;
|
uint32 _extranonce;
|
||||||
boost::mutex _mtxExtranonce;
|
boost::mutex _mtxExtranonce;
|
||||||
|
@ -4,7 +4,7 @@ file(GLOB_RECURSE sources_MySQL MySQL/*.cpp MySQL/*.h)
|
|||||||
file(GLOB_RECURSE sources_Logging Logging/*.cpp Logging/*.h)
|
file(GLOB_RECURSE sources_Logging Logging/*.cpp Logging/*.h)
|
||||||
file(GLOB_RECURSE sources_JSON JSON/*.cpp JSON/*.h)
|
file(GLOB_RECURSE sources_JSON JSON/*.cpp JSON/*.h)
|
||||||
file(GLOB_RECURSE sources_JSONRPC JSONRPC/*.cpp JSONRPC/*.h)
|
file(GLOB_RECURSE sources_JSONRPC JSONRPC/*.cpp JSONRPC/*.h)
|
||||||
file(GLOB_RECURSE sources_Bitcoin Bitcoin/*.cpp Bitcoin/*.h)
|
file(GLOB_RECURSE sources_Gostcoin Gostcoin/*.cpp Gostcoin/*.h)
|
||||||
|
|
||||||
file(GLOB sources_localdir *.cpp *.h)
|
file(GLOB sources_localdir *.cpp *.h)
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ set(sources_Shared
|
|||||||
${sources_Logging}
|
${sources_Logging}
|
||||||
${sources_JSON}
|
${sources_JSON}
|
||||||
${sources_JSONRPC}
|
${sources_JSONRPC}
|
||||||
${sources_Bitcoin}
|
${sources_Gostcoin}
|
||||||
${sources_localdir}
|
${sources_localdir}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ include_directories(
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/Logging
|
${CMAKE_CURRENT_SOURCE_DIR}/Logging
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/JSON
|
${CMAKE_CURRENT_SOURCE_DIR}/JSON
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/JSONRPC
|
${CMAKE_CURRENT_SOURCE_DIR}/JSONRPC
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/Bitcoin
|
${CMAKE_CURRENT_SOURCE_DIR}/Gostcoin
|
||||||
${Boost_INCLUDE_DIR}
|
${Boost_INCLUDE_DIR}
|
||||||
${MYSQL_INCLUDE_DIR}
|
${MYSQL_INCLUDE_DIR}
|
||||||
${GMP_INCLUDE_DIR}
|
${GMP_INCLUDE_DIR}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "Block.h"
|
#include "Block.h"
|
||||||
|
|
||||||
namespace Bitcoin
|
namespace Gostcoin
|
||||||
{
|
{
|
||||||
void Block::BuildMerkleTree()
|
void Block::BuildMerkleTree()
|
||||||
{
|
{
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef BITCOIN_BLOCK_H_
|
#ifndef GOSTCOIN_BLOCK_H_
|
||||||
#define BITCOIN_BLOCK_H_
|
#define GOSTCOIN_BLOCK_H_
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "Transaction.h"
|
#include "Transaction.h"
|
||||||
@ -7,7 +7,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
namespace Bitcoin
|
namespace Gostcoin
|
||||||
{
|
{
|
||||||
class BlockHeader
|
class BlockHeader
|
||||||
{
|
{
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef BITCOIN_H_
|
#ifndef GOSTCOIN_H_
|
||||||
#define BITCOIN_H_
|
#define GOSTCOIN_H_
|
||||||
|
|
||||||
#include "Block.h"
|
#include "Block.h"
|
||||||
#include "Transaction.h"
|
#include "Transaction.h"
|
||||||
@ -8,7 +8,7 @@
|
|||||||
#include "BigNum.h"
|
#include "BigNum.h"
|
||||||
#include <gmpxx.h>
|
#include <gmpxx.h>
|
||||||
|
|
||||||
namespace Bitcoin
|
namespace Gostcoin
|
||||||
{
|
{
|
||||||
inline BigInt TargetToDiff(BigInt val)
|
inline BigInt TargetToDiff(BigInt val)
|
||||||
{
|
{
|
||||||
@ -40,7 +40,7 @@ namespace Bitcoin
|
|||||||
ByteBuffer scriptsig;
|
ByteBuffer scriptsig;
|
||||||
scriptsig << blockHeight << extranonce_ph;
|
scriptsig << blockHeight << extranonce_ph;
|
||||||
|
|
||||||
Bitcoin::OutPoint outpoint;
|
Gostcoin::OutPoint outpoint;
|
||||||
outpoint.hash.resize(32, 0);
|
outpoint.hash.resize(32, 0);
|
||||||
outpoint.n = 0xFFFFFFFF;
|
outpoint.n = 0xFFFFFFFF;
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ namespace Bitcoin
|
|||||||
|
|
||||||
TxOut txout;
|
TxOut txout;
|
||||||
txout.value = value;
|
txout.value = value;
|
||||||
txout.scriptPubKey = Bitcoin::Script(pubkey) + Bitcoin::OP_CHECKSIG;
|
txout.scriptPubKey = Gostcoin::Script(pubkey) + Gostcoin::OP_CHECKSIG;
|
||||||
|
|
||||||
Transaction tx;
|
Transaction tx;
|
||||||
tx.version = 1;
|
tx.version = 1;
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef BITCOIN_SCRIPT_H_
|
#ifndef GOSTCOIN_SCRIPT_H_
|
||||||
#define BITCOIN_SCRIPT_H_
|
#define GOSTCOIN_SCRIPT_H_
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "ByteBuffer.h"
|
#include "ByteBuffer.h"
|
||||||
@ -7,7 +7,7 @@
|
|||||||
#include <boost/range/join.hpp>
|
#include <boost/range/join.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace Bitcoin
|
namespace Gostcoin
|
||||||
{
|
{
|
||||||
enum ScriptOPCode
|
enum ScriptOPCode
|
||||||
{
|
{
|
@ -3,10 +3,10 @@
|
|||||||
#include "Transaction.h"
|
#include "Transaction.h"
|
||||||
#include "Block.h"
|
#include "Block.h"
|
||||||
|
|
||||||
using namespace Bitcoin;
|
using namespace Gostcoin;
|
||||||
|
|
||||||
// VarInt
|
// VarInt
|
||||||
ByteBuffer& Bitcoin::operator<<(ByteBuffer& a, VarInt& b)
|
ByteBuffer& Gostcoin::operator<<(ByteBuffer& a, VarInt& b)
|
||||||
{
|
{
|
||||||
if (b.value < 0xfd) {
|
if (b.value < 0xfd) {
|
||||||
a.Append<uint8>(b.value);
|
a.Append<uint8>(b.value);
|
||||||
@ -22,7 +22,7 @@ ByteBuffer& Bitcoin::operator<<(ByteBuffer& a, VarInt& b)
|
|||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
ByteBuffer& Bitcoin::operator>>(ByteBuffer& a, VarInt& b)
|
ByteBuffer& Gostcoin::operator>>(ByteBuffer& a, VarInt& b)
|
||||||
{
|
{
|
||||||
uint8 size = a.Read<uint8>();
|
uint8 size = a.Read<uint8>();
|
||||||
|
|
||||||
@ -37,14 +37,14 @@ ByteBuffer& Bitcoin::operator>>(ByteBuffer& a, VarInt& b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Script
|
// Script
|
||||||
ByteBuffer& Bitcoin::operator<<(ByteBuffer& a, Script& b)
|
ByteBuffer& Gostcoin::operator<<(ByteBuffer& a, Script& b)
|
||||||
{
|
{
|
||||||
VarInt size(b.script.size());
|
VarInt size(b.script.size());
|
||||||
a << size;
|
a << size;
|
||||||
a << b.script;
|
a << b.script;
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
ByteBuffer& Bitcoin::operator>>(ByteBuffer& a, Script& b)
|
ByteBuffer& Gostcoin::operator>>(ByteBuffer& a, Script& b)
|
||||||
{
|
{
|
||||||
VarInt size;
|
VarInt size;
|
||||||
a >> size;
|
a >> size;
|
||||||
@ -53,13 +53,13 @@ ByteBuffer& Bitcoin::operator>>(ByteBuffer& a, Script& b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// OutPoint
|
// OutPoint
|
||||||
ByteBuffer& Bitcoin::operator<<(ByteBuffer& a, OutPoint& b)
|
ByteBuffer& Gostcoin::operator<<(ByteBuffer& a, OutPoint& b)
|
||||||
{
|
{
|
||||||
a << b.hash;
|
a << b.hash;
|
||||||
a << b.n;
|
a << b.n;
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
ByteBuffer& Bitcoin::operator>>(ByteBuffer& a, OutPoint& b)
|
ByteBuffer& Gostcoin::operator>>(ByteBuffer& a, OutPoint& b)
|
||||||
{
|
{
|
||||||
b.hash = a.ReadBinary(32);
|
b.hash = a.ReadBinary(32);
|
||||||
a >> b.n;
|
a >> b.n;
|
||||||
@ -67,14 +67,14 @@ ByteBuffer& Bitcoin::operator>>(ByteBuffer& a, OutPoint& b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TxIn
|
// TxIn
|
||||||
ByteBuffer& Bitcoin::operator<<(ByteBuffer& a, TxIn& b)
|
ByteBuffer& Gostcoin::operator<<(ByteBuffer& a, TxIn& b)
|
||||||
{
|
{
|
||||||
a << b.prevout;
|
a << b.prevout;
|
||||||
a << b.script;
|
a << b.script;
|
||||||
a << b.n;
|
a << b.n;
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
ByteBuffer& Bitcoin::operator>>(ByteBuffer& a, TxIn& b)
|
ByteBuffer& Gostcoin::operator>>(ByteBuffer& a, TxIn& b)
|
||||||
{
|
{
|
||||||
a >> b.prevout;
|
a >> b.prevout;
|
||||||
a >> b.script;
|
a >> b.script;
|
||||||
@ -83,13 +83,13 @@ ByteBuffer& Bitcoin::operator>>(ByteBuffer& a, TxIn& b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TxOut
|
// TxOut
|
||||||
ByteBuffer& Bitcoin::operator<<(ByteBuffer& a, TxOut& b)
|
ByteBuffer& Gostcoin::operator<<(ByteBuffer& a, TxOut& b)
|
||||||
{
|
{
|
||||||
a << b.value;
|
a << b.value;
|
||||||
a << b.scriptPubKey;
|
a << b.scriptPubKey;
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
ByteBuffer& Bitcoin::operator>>(ByteBuffer& a, TxOut& b)
|
ByteBuffer& Gostcoin::operator>>(ByteBuffer& a, TxOut& b)
|
||||||
{
|
{
|
||||||
a >> b.value;
|
a >> b.value;
|
||||||
a >> b.scriptPubKey;
|
a >> b.scriptPubKey;
|
||||||
@ -97,7 +97,7 @@ ByteBuffer& Bitcoin::operator>>(ByteBuffer& a, TxOut& b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Transaction
|
// Transaction
|
||||||
ByteBuffer& Bitcoin::operator<<(ByteBuffer& a, Transaction& b)
|
ByteBuffer& Gostcoin::operator<<(ByteBuffer& a, Transaction& b)
|
||||||
{
|
{
|
||||||
a << b.version;
|
a << b.version;
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ ByteBuffer& Bitcoin::operator<<(ByteBuffer& a, Transaction& b)
|
|||||||
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
ByteBuffer& Bitcoin::operator>>(ByteBuffer& a, Transaction& b)
|
ByteBuffer& Gostcoin::operator>>(ByteBuffer& a, Transaction& b)
|
||||||
{
|
{
|
||||||
a >> b.version;
|
a >> b.version;
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ ByteBuffer& Bitcoin::operator>>(ByteBuffer& a, Transaction& b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Block
|
// Block
|
||||||
ByteBuffer& Bitcoin::operator<<(ByteBuffer& a, Block& b)
|
ByteBuffer& Gostcoin::operator<<(ByteBuffer& a, Block& b)
|
||||||
{
|
{
|
||||||
a << b.version;
|
a << b.version;
|
||||||
a << b.prevBlockHash;
|
a << b.prevBlockHash;
|
||||||
@ -160,7 +160,7 @@ ByteBuffer& Bitcoin::operator<<(ByteBuffer& a, Block& b)
|
|||||||
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
ByteBuffer& Bitcoin::operator>>(ByteBuffer& a, Block& b)
|
ByteBuffer& Gostcoin::operator>>(ByteBuffer& a, Block& b)
|
||||||
{
|
{
|
||||||
a >> b.version;
|
a >> b.version;
|
||||||
b.prevBlockHash = a.ReadBinary(32);
|
b.prevBlockHash = a.ReadBinary(32);
|
@ -1,7 +1,7 @@
|
|||||||
#include "Transaction.h"
|
#include "Transaction.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
|
|
||||||
namespace Bitcoin
|
namespace Gostcoin
|
||||||
{
|
{
|
||||||
BinaryData Transaction::GetHash()
|
BinaryData Transaction::GetHash()
|
||||||
{
|
{
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef BITCOIN_TRANSACTION_H_
|
#ifndef GOSTCOIN_TRANSACTION_H_
|
||||||
#define BITCOIN_TRANSACTION_H_
|
#define GOSTCOIN_TRANSACTION_H_
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "ByteBuffer.h"
|
#include "ByteBuffer.h"
|
||||||
@ -7,7 +7,7 @@
|
|||||||
#include "Script.h"
|
#include "Script.h"
|
||||||
#include "Crypto.h"
|
#include "Crypto.h"
|
||||||
|
|
||||||
namespace Bitcoin
|
namespace Gostcoin
|
||||||
{
|
{
|
||||||
class OutPoint
|
class OutPoint
|
||||||
{
|
{
|
@ -1,10 +1,10 @@
|
|||||||
#ifndef BITCOIN_VARINT_H_
|
#ifndef GOSTCOIN_VARINT_H_
|
||||||
#define BITCOIN_VARINT_H_
|
#define GOSTCOIN_VARINT_H_
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "ByteBuffer.h"
|
#include "ByteBuffer.h"
|
||||||
|
|
||||||
namespace Bitcoin
|
namespace Gostcoin
|
||||||
{
|
{
|
||||||
class VarInt
|
class VarInt
|
||||||
{
|
{
|
Loading…
x
Reference in New Issue
Block a user