Value getstakesubsidy(const Array& params, bool fHelp) { if (fHelp || params.size() != 1) throw runtime_error( "getstakesubsidy <hex string>\n" "Returns proof-of-stake subsidy value for the specified coinstake."); RPCTypeCheck(params, list_of(str_type)); vector<unsigned char> txData(ParseHex(params[0].get_str())); CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION); CTransaction tx; try { ssData >> tx; } catch (std::exception &e) { throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed"); } uint64_t nCoinAge; CTxDB txdb("r"); if (!tx.GetCoinAge(txdb, pindexBest, nCoinAge)) throw JSONRPCError(RPC_MISC_ERROR, "GetCoinAge failed"); return (uint64_t)GetProofOfStakeReward(pindexBest, nCoinAge, 0); }