Skip to content

Commit

Permalink
Bitcore 0.14.0 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
karelbilek committed Apr 2, 2017
1 parent 06efaec commit 539d7ec
Show file tree
Hide file tree
Showing 13 changed files with 169 additions and 161 deletions.
2 changes: 1 addition & 1 deletion qa/rpc-tests/txindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def run_test(self):
scriptPubKey = CScript([OP_DUP, OP_HASH160, addressHash, OP_EQUALVERIFY, OP_CHECKSIG])
unspent = self.nodes[0].listunspent()
tx = CTransaction()
amount = int(unspent[0]["amount"] * 100000000)
amount = int(unspent[0]["amount"] * 10000000)
tx.vin = [CTxIn(COutPoint(int(unspent[0]["txid"], 16), unspent[0]["vout"]))]
tx.vout = [CTxOut(amount, scriptPubKey)]
tx.rehash()
Expand Down
50 changes: 25 additions & 25 deletions src/addressindex.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ struct CAddressUnspentKey {
uint256 txhash;
size_t index;

size_t GetSerializeSize(int nType, int nVersion) const {
size_t GetSerializeSize() const {
return 57;
}
template<typename Stream>
void Serialize(Stream& s, int nType, int nVersion) const {
void Serialize(Stream& s) const {
ser_writedata8(s, type);
hashBytes.Serialize(s, nType, nVersion);
txhash.Serialize(s, nType, nVersion);
hashBytes.Serialize(s);
txhash.Serialize(s);
ser_writedata32(s, index);
}
template<typename Stream>
void Unserialize(Stream& s, int nType, int nVersion) {
void Unserialize(Stream& s) {
type = ser_readdata8(s);
hashBytes.Unserialize(s, nType, nVersion);
txhash.Unserialize(s, nType, nVersion);
hashBytes.Unserialize(s);
txhash.Unserialize(s);
index = ser_readdata32(s);
}

Expand Down Expand Up @@ -61,7 +61,7 @@ struct CAddressUnspentValue {
ADD_SERIALIZE_METHODS;

template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
inline void SerializationOp(Stream& s, Operation ser_action) {
READWRITE(satoshis);
READWRITE(*(CScriptBase*)(&script));
READWRITE(blockHeight);
Expand Down Expand Up @@ -97,28 +97,28 @@ struct CAddressIndexKey {
size_t index;
bool spending;

size_t GetSerializeSize(int nType, int nVersion) const {
size_t GetSerializeSize() const {
return 66;
}
template<typename Stream>
void Serialize(Stream& s, int nType, int nVersion) const {
void Serialize(Stream& s) const {
ser_writedata8(s, type);
hashBytes.Serialize(s, nType, nVersion);
hashBytes.Serialize(s);
// Heights are stored big-endian for key sorting in LevelDB
ser_writedata32be(s, blockHeight);
ser_writedata32be(s, txindex);
txhash.Serialize(s, nType, nVersion);
txhash.Serialize(s);
ser_writedata32(s, index);
char f = spending;
ser_writedata8(s, f);
}
template<typename Stream>
void Unserialize(Stream& s, int nType, int nVersion) {
void Unserialize(Stream& s) {
type = ser_readdata8(s);
hashBytes.Unserialize(s, nType, nVersion);
hashBytes.Unserialize(s);
blockHeight = ser_readdata32be(s);
txindex = ser_readdata32be(s);
txhash.Unserialize(s, nType, nVersion);
txhash.Unserialize(s);
index = ser_readdata32(s);
char f = ser_readdata8(s);
spending = f;
Expand Down Expand Up @@ -155,18 +155,18 @@ struct CAddressIndexIteratorKey {
unsigned int type;
uint160 hashBytes;

size_t GetSerializeSize(int nType, int nVersion) const {
size_t GetSerializeSize() const {
return 21;
}
template<typename Stream>
void Serialize(Stream& s, int nType, int nVersion) const {
void Serialize(Stream& s) const {
ser_writedata8(s, type);
hashBytes.Serialize(s, nType, nVersion);
hashBytes.Serialize(s);
}
template<typename Stream>
void Unserialize(Stream& s, int nType, int nVersion) {
void Unserialize(Stream& s) {
type = ser_readdata8(s);
hashBytes.Unserialize(s, nType, nVersion);
hashBytes.Unserialize(s);
}

CAddressIndexIteratorKey(unsigned int addressType, uint160 addressHash) {
Expand All @@ -189,19 +189,19 @@ struct CAddressIndexIteratorHeightKey {
uint160 hashBytes;
int blockHeight;

size_t GetSerializeSize(int nType, int nVersion) const {
size_t GetSerializeSize() const {
return 25;
}
template<typename Stream>
void Serialize(Stream& s, int nType, int nVersion) const {
void Serialize(Stream& s) const {
ser_writedata8(s, type);
hashBytes.Serialize(s, nType, nVersion);
hashBytes.Serialize(s);
ser_writedata32be(s, blockHeight);
}
template<typename Stream>
void Unserialize(Stream& s, int nType, int nVersion) {
void Unserialize(Stream& s) {
type = ser_readdata8(s);
hashBytes.Unserialize(s, nType, nVersion);
hashBytes.Unserialize(s);
blockHeight = ser_readdata32be(s);
}

Expand Down
28 changes: 14 additions & 14 deletions src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex)
UniValue deltas(UniValue::VARR);

for (unsigned int i = 0; i < block.vtx.size(); i++) {
const CTransaction &tx = block.vtx[i];
const CTransaction &tx = *(block.vtx[i]);
const uint256 txhash = tx.GetHash();

UniValue entry(UniValue::VOBJ);
Expand Down Expand Up @@ -714,12 +714,12 @@ UniValue getmempoolentry(const JSONRPCRequest& request)
return info;
}

UniValue getblockdeltas(const UniValue& params, bool fHelp)
UniValue getblockdeltas(const JSONRPCRequest& request)
{
if (fHelp || params.size() != 1)
if (request.fHelp || request.params.size() != 1)
throw runtime_error("");

std::string strHash = params[0].get_str();
std::string strHash = request.params[0].get_str();
uint256 hash(uint256S(strHash));

if (mapBlockIndex.count(hash) == 0)
Expand All @@ -737,9 +737,9 @@ UniValue getblockdeltas(const UniValue& params, bool fHelp)
return blockToDeltasJSON(block, pblockindex);
}

UniValue getblockhashes(const UniValue& params, bool fHelp)
UniValue getblockhashes(const JSONRPCRequest& request)
{
if (fHelp || params.size() < 2)
if (request.fHelp || request.params.size() < 2)
throw runtime_error(
"getblockhashes timestamp\n"
"\nReturns array of hashes of blocks within the timestamp range provided.\n"
Expand Down Expand Up @@ -767,15 +767,15 @@ UniValue getblockhashes(const UniValue& params, bool fHelp)
+ HelpExampleCli("getblockhashes", "1231614698 1231024505 '{\"noOrphans\":false, \"logicalTimes\":true}'")
);

unsigned int high = params[0].get_int();
unsigned int low = params[1].get_int();
unsigned int high = request.params[0].get_int();
unsigned int low = request.params[1].get_int();
bool fActiveOnly = false;
bool fLogicalTS = false;

if (params.size() > 2) {
if (params[2].isObject()) {
UniValue noOrphans = find_value(params[2].get_obj(), "noOrphans");
UniValue returnLogical = find_value(params[2].get_obj(), "logicalTimes");
if (request.params.size() > 2) {
if (request.params[2].isObject()) {
UniValue noOrphans = find_value(request.params[2].get_obj(), "noOrphans");
UniValue returnLogical = find_value(request.params[2].get_obj(), "logicalTimes");

if (noOrphans.isBool())
fActiveOnly = noOrphans.get_bool();
Expand Down Expand Up @@ -1629,8 +1629,8 @@ static const CRPCCommand commands[] =
{ "blockchain", "getbestblockhash", &getbestblockhash, true, {} },
{ "blockchain", "getblockcount", &getblockcount, true, {} },
{ "blockchain", "getblock", &getblock, true, {"blockhash","verbose"} },
{ "blockchain", "getblockdeltas", &getblockdeltas, false },
{ "blockchain", "getblockhashes", &getblockhashes, true },
{ "blockchain", "getblockdeltas", &getblockdeltas, false, {} },
{ "blockchain", "getblockhashes", &getblockhashes, true, {} },
{ "blockchain", "getblockhash", &getblockhash, true, {"height"} },
{ "blockchain", "getblockheader", &getblockheader, true, {"blockhash","verbose"} },
{ "blockchain", "getchaintips", &getchaintips, true, {} },
Expand Down
18 changes: 9 additions & 9 deletions src/rpc/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "setnetworkactive", 0, "state" },
{ "getmempoolancestors", 1, "verbose" },
{ "getmempooldescendants", 1, "verbose" },
{ "getblockhashes", 0 },
{ "getblockhashes", 1 },
{ "getblockhashes", 2 },
{ "getspentinfo", 0},
{ "getaddresstxids", 0},
{ "getaddressbalance", 0},
{ "getaddressdeltas", 0},
{ "getaddressutxos", 0},
{ "getaddressmempool", 0},
{ "getblockhashes", 0 , "high"},
{ "getblockhashes", 1, "low"},
{ "getblockhashes", 2, "options" },
{ "getspentinfo", 0, "txid_index"},
{ "getaddresstxids", 0, "addresses"},
{ "getaddressbalance", 0, "addresses"},
{ "getaddressdeltas", 0, "addresses"},
{ "getaddressutxos", 0, "addresses"},
{ "getaddressmempool", 0, "addresses"},
{ "bumpfee", 1, "options" },
// Echo with conversion (For testing only)
{ "echojson", 0, "arg0" },
Expand Down
Loading

0 comments on commit 539d7ec

Please sign in to comment.