mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-02-04 19:24:20 +00:00
Fixed CN RPC call transfer.
This commit is contained in:
parent
b39ed3748d
commit
8766247be1
@ -13,6 +13,7 @@
|
|||||||
#include <crypto/common.h>
|
#include <crypto/common.h>
|
||||||
|
|
||||||
extern "C" void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int prehashed, uint64_t height);
|
extern "C" void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int prehashed, uint64_t height);
|
||||||
|
extern "C" void cn_fast_hash(const void *data, size_t length, char *hash);
|
||||||
|
|
||||||
uint256 CBlockHeader::GetHash() const
|
uint256 CBlockHeader::GetHash() const
|
||||||
{
|
{
|
||||||
@ -21,6 +22,27 @@ uint256 CBlockHeader::GetHash() const
|
|||||||
return hashWriter.GetHash();
|
return hashWriter.GetHash();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256 CBlockHeader::GetCryptonoteFastHash() const
|
||||||
|
{
|
||||||
|
uint256 thash;
|
||||||
|
if (hashPrevBlock.IsNull()) {
|
||||||
|
// Genesis block has no CN fast hash.
|
||||||
|
memset(thash.begin(), 0xff, thash.size());
|
||||||
|
return thash;
|
||||||
|
}
|
||||||
|
|
||||||
|
// prev_id of CN header is used to store the kevacoin block hash.
|
||||||
|
// The value of prev_id and block hash must be the same to prove
|
||||||
|
// that PoW has been properly done.
|
||||||
|
if (GetHash() != cnHeader.prev_id) {
|
||||||
|
memset(thash.begin(), 0xff, thash.size());
|
||||||
|
return thash;
|
||||||
|
}
|
||||||
|
cryptonote::blobdata blob = cryptonote::t_serializable_object_to_blob(cnHeader);
|
||||||
|
cn_fast_hash(blob.data(), blob.size(), BEGIN(thash));
|
||||||
|
return thash;
|
||||||
|
}
|
||||||
|
|
||||||
uint256 CBlockHeader::GetPoWHash() const
|
uint256 CBlockHeader::GetPoWHash() const
|
||||||
{
|
{
|
||||||
uint256 thash;
|
uint256 thash;
|
||||||
|
@ -167,6 +167,8 @@ public:
|
|||||||
|
|
||||||
uint256 GetHash() const;
|
uint256 GetHash() const;
|
||||||
|
|
||||||
|
uint256 GetCryptonoteFastHash() const;
|
||||||
|
|
||||||
uint256 GetPoWHash() const;
|
uint256 GetPoWHash() const;
|
||||||
|
|
||||||
int64_t GetBlockTime() const
|
int64_t GetBlockTime() const
|
||||||
|
@ -753,13 +753,17 @@ UniValue getlastblockheader(const JSONRPCRequest& request)
|
|||||||
blockHeader.push_back(Pair("minor_version", (uint64_t)block.cnHeader.minor_version));
|
blockHeader.push_back(Pair("minor_version", (uint64_t)block.cnHeader.minor_version));
|
||||||
|
|
||||||
blockHeader.push_back(Pair("timestamp", (uint64_t)pblockindex->nTime));
|
blockHeader.push_back(Pair("timestamp", (uint64_t)pblockindex->nTime));
|
||||||
blockHeader.push_back(Pair("prev_hash", pblockindex->pprev->GetBlockHash().GetHex()));
|
if (pblockindex->pprev) {
|
||||||
|
blockHeader.push_back(Pair("prev_hash", pblockindex->pprev->GetBlockHash().GetHex()));
|
||||||
|
} else {
|
||||||
|
blockHeader.push_back(Pair("prev_hash", ""));
|
||||||
|
}
|
||||||
blockHeader.push_back(Pair("nonce", (uint64_t)pblockindex->nNonce));
|
blockHeader.push_back(Pair("nonce", (uint64_t)pblockindex->nNonce));
|
||||||
blockHeader.push_back(Pair("orphan_status", false));
|
blockHeader.push_back(Pair("orphan_status", false));
|
||||||
blockHeader.push_back(Pair("height", (uint64_t)pblockindex->nHeight));
|
blockHeader.push_back(Pair("height", (uint64_t)pblockindex->nHeight));
|
||||||
const uint64_t depth = chainActive.Height() - pblockindex->nHeight + 1; // Same as confirmations.
|
const uint64_t depth = chainActive.Height() - pblockindex->nHeight + 1; // Same as confirmations.
|
||||||
blockHeader.push_back(Pair("depth", (uint64_t)depth));
|
blockHeader.push_back(Pair("depth", (uint64_t)depth));
|
||||||
blockHeader.push_back(Pair("hash", pblockindex->GetBlockHash().GetHex()));
|
blockHeader.push_back(Pair("hash", block.GetCryptonoteFastHash().GetHex()));
|
||||||
blockHeader.push_back(Pair("difficulty", GetDifficulty(pblockindex)));
|
blockHeader.push_back(Pair("difficulty", GetDifficulty(pblockindex)));
|
||||||
|
|
||||||
// TODO: implement cumulative_difficulty
|
// TODO: implement cumulative_difficulty
|
||||||
@ -832,13 +836,17 @@ UniValue getblockheaderbyheight(const JSONRPCRequest& request)
|
|||||||
blockHeader.push_back(Pair("minor_version", (uint64_t)block.cnHeader.minor_version));
|
blockHeader.push_back(Pair("minor_version", (uint64_t)block.cnHeader.minor_version));
|
||||||
|
|
||||||
blockHeader.push_back(Pair("timestamp", (uint64_t)pblockindex->nTime));
|
blockHeader.push_back(Pair("timestamp", (uint64_t)pblockindex->nTime));
|
||||||
blockHeader.push_back(Pair("prev_hash", pblockindex->pprev->GetBlockHash().GetHex()));
|
if (pblockindex->pprev) {
|
||||||
|
blockHeader.push_back(Pair("prev_hash", pblockindex->pprev->GetBlockHash().GetHex()));
|
||||||
|
} else {
|
||||||
|
blockHeader.push_back(Pair("prev_hash", ""));
|
||||||
|
}
|
||||||
blockHeader.push_back(Pair("nonce", (uint64_t)pblockindex->nNonce));
|
blockHeader.push_back(Pair("nonce", (uint64_t)pblockindex->nNonce));
|
||||||
blockHeader.push_back(Pair("orphan_status", false));
|
blockHeader.push_back(Pair("orphan_status", false));
|
||||||
blockHeader.push_back(Pair("height", (uint64_t)pblockindex->nHeight));
|
blockHeader.push_back(Pair("height", (uint64_t)pblockindex->nHeight));
|
||||||
const uint64_t depth = chainActive.Height() - nHeight + 1; // Same as confirmations.
|
const uint64_t depth = chainActive.Height() - nHeight + 1; // Same as confirmations.
|
||||||
blockHeader.push_back(Pair("depth", (uint64_t)depth));
|
blockHeader.push_back(Pair("depth", (uint64_t)depth));
|
||||||
blockHeader.push_back(Pair("hash", pblockindex->GetBlockHash().GetHex()));
|
blockHeader.push_back(Pair("hash", block.GetCryptonoteFastHash().GetHex()));
|
||||||
blockHeader.push_back(Pair("difficulty", GetDifficulty(pblockindex)));
|
blockHeader.push_back(Pair("difficulty", GetDifficulty(pblockindex)));
|
||||||
|
|
||||||
// TODO: implement cumulative_difficulty
|
// TODO: implement cumulative_difficulty
|
||||||
|
@ -3785,7 +3785,7 @@ static const CRPCCommand commands[] =
|
|||||||
{ "wallet", "walletpassphrase", &walletpassphrase, {"passphrase","timeout"} },
|
{ "wallet", "walletpassphrase", &walletpassphrase, {"passphrase","timeout"} },
|
||||||
{ "wallet", "removeprunedfunds", &removeprunedfunds, {"txid"} },
|
{ "wallet", "removeprunedfunds", &removeprunedfunds, {"txid"} },
|
||||||
{ "wallet", "rescanblockchain", &rescanblockchain, {"start_height", "stop_height"} },
|
{ "wallet", "rescanblockchain", &rescanblockchain, {"start_height", "stop_height"} },
|
||||||
{ "wallet", "transfer", &transfer, {"destinations"} },
|
{ "wallet", "transfer", &transfer, {"destinations", "account_index", "subaddr_indices", "priority", "mixin", "ring_size", "unlock_time", "payment_id", "get_tx_key", "do_not_relay", "get_tx_hex", "get_tx_metadata"} },
|
||||||
|
|
||||||
{ "generating", "generate", &generate, {"nblocks","maxtries"} },
|
{ "generating", "generate", &generate, {"nblocks","maxtries"} },
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user