|
|
@ -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); |