X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fbitcoinrpc.cpp;h=03c01f7b2160fd71f665f62cfc1f07d387d8fdba;hb=2bc4fd609ca00d5a5cb0b6b3eba5f35cb334b967;hp=57deed9af4d5c9e8e17f73d9959c2cc74b364bb6;hpb=6950bb6200cb71d0a1932e80c3aa563391fe6627;p=novacoin.git diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 57deed9..03c01f7 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -368,11 +368,14 @@ Value getmininginfo(const Array& params, bool fHelp) Object obj; obj.push_back(Pair("blocks", (int)nBestHeight)); + obj.push_back(Pair("currentblocksize",(uint64_t)nLastBlockSize)); + obj.push_back(Pair("currentblocktx",(uint64_t)nLastBlockTx)); obj.push_back(Pair("difficulty", (double)GetDifficulty())); obj.push_back(Pair("errors", GetWarnings("statusbar"))); obj.push_back(Pair("generate", (bool)fGenerateBitcoins)); obj.push_back(Pair("genproclimit", (int)(fLimitProcessors ? nLimitProcessors : -1))); obj.push_back(Pair("hashespersec", gethashespersec(params, false))); + obj.push_back(Pair("pooledtx", (uint64_t)nPooledTx)); obj.push_back(Pair("testnet", fTestNet)); return obj; } @@ -586,8 +589,6 @@ Value sendtoaddress(const Array& params, bool fHelp) return wtx.GetHash().GetHex(); } -static const string strMessageMagic = "Bitcoin Signed Message:\n"; - Value signmessage(const Array& params, bool fHelp) { if (fHelp || params.size() != 2) @@ -991,7 +992,7 @@ Value addmultisigaddress(const Array& params, bool fHelp) { string msg = "addmultisigaddress <'[\"key\",\"key\"]'> [account]\n" "Add a nrequired-to-sign multisignature address to the wallet\"\n" - "each key is a bitcoin address, hex or base58 public key\n" + "each key is a bitcoin address or hex-encoded public key\n" "If [account] is specified, assign address to [account]."; throw runtime_error(msg); } @@ -1005,41 +1006,52 @@ Value addmultisigaddress(const Array& params, bool fHelp) strAccount = AccountFromValue(params[2]); // Gather public keys - if (keys.size() < nRequired) + if (nRequired < 1 || keys.size() < nRequired) throw runtime_error( - strprintf("addmultisigaddress: wrong number of keys (got %d, need at least %d)", keys.size(), nRequired)); + strprintf("wrong number of keys" + "(got %d, need at least %d)", keys.size(), nRequired)); std::vector pubkeys; pubkeys.resize(keys.size()); for (int i = 0; i < keys.size(); i++) { const std::string& ks = keys[i].get_str(); - if (ks.size() == 130) // hex public key - pubkeys[i].SetPubKey(ParseHex(ks)); - else if (ks.size() > 34) // base58-encoded + + // Case 1: bitcoin address and we have full public key: + CBitcoinAddress address(ks); + if (address.IsValid()) { + if (address.IsScript()) + throw runtime_error( + strprintf("%s is a pay-to-script address",ks.c_str())); std::vector vchPubKey; - if (DecodeBase58(ks, vchPubKey)) - pubkeys[i].SetPubKey(vchPubKey); - else - throw runtime_error("Error base58 decoding key: "+ks); + if (!pwalletMain->GetPubKey(address, vchPubKey)) + throw runtime_error( + strprintf("no full public key for address %s",ks.c_str())); + if (vchPubKey.empty() || !pubkeys[i].SetPubKey(vchPubKey)) + throw runtime_error(" Invalid public key: "+ks); } - else // bitcoin address for key in this wallet + + // Case 2: hex public key + else if (IsHex(ks)) { - CBitcoinAddress address(ks); - if (!pwalletMain->GetKey(address, pubkeys[i])) - throw runtime_error( - strprintf("addmultisigaddress: unknown address: %s",ks.c_str())); + vector vchPubKey = ParseHex(ks); + if (vchPubKey.empty() || !pubkeys[i].SetPubKey(vchPubKey)) + throw runtime_error(" Invalid public key: "+ks); + } + else + { + throw runtime_error(" Invalid public key: "+ks); } } - // Construct using OP_EVAL + // Construct using pay-to-script-hash: CScript inner; inner.SetMultisig(nRequired, pubkeys); uint160 scriptHash = Hash160(inner); CScript scriptPubKey; - scriptPubKey.SetEval(inner); - pwalletMain->AddCScript(scriptHash, inner); + scriptPubKey.SetPayToScriptHash(inner); + pwalletMain->AddCScript(inner); CBitcoinAddress address; address.SetScriptHash160(scriptHash); @@ -1434,7 +1446,7 @@ Value listsinceblock(const Array& params, bool fHelp) CBlockIndex *block; for (block = pindexBest; block && block->nHeight > target_height; - block = block->pprev); + block = block->pprev) { } lastblock = block ? block->GetBlockHash() : 0; } @@ -1715,8 +1727,6 @@ Value validateaddress(const Array& params, bool fHelp) std::vector vchPubKey; pwalletMain->GetPubKey(address, vchPubKey); ret.push_back(Pair("pubkey", HexStr(vchPubKey))); - std::string strPubKey(vchPubKey.begin(), vchPubKey.end()); - ret.push_back(Pair("pubkey58", EncodeBase58(vchPubKey))); CKey key; key.SetPubKey(vchPubKey); ret.push_back(Pair("iscompressed", key.IsCompressed())); @@ -1862,7 +1872,10 @@ Value getmemorypool(const Array& params, bool fHelp) " \"previousblockhash\" : hash of current highest block\n" " \"transactions\" : contents of non-coinbase transactions that should be included in the next block\n" " \"coinbasevalue\" : maximum allowable input to coinbase transaction, including the generation award and transaction fees\n" + " \"coinbaseflags\" : data that should be included in coinbase so support for new features can be judged\n" " \"time\" : timestamp appropriate for next block\n" + " \"mintime\" : minimum timestamp appropriate for next block\n" + " \"curtime\" : current timestamp\n" " \"bits\" : compressed target of next block\n" "If [data] is specified, tries to solve the block and returns true if it was successful."); @@ -1916,7 +1929,10 @@ Value getmemorypool(const Array& params, bool fHelp) result.push_back(Pair("previousblockhash", pblock->hashPrevBlock.GetHex())); result.push_back(Pair("transactions", transactions)); result.push_back(Pair("coinbasevalue", (int64_t)pblock->vtx[0].vout[0].nValue)); + result.push_back(Pair("coinbaseflags", HexStr(COINBASE_FLAGS.begin(), COINBASE_FLAGS.end()))); result.push_back(Pair("time", (int64_t)pblock->nTime)); + result.push_back(Pair("mintime", (int64_t)pindexPrev->GetMedianTimePast()+1)); + result.push_back(Pair("curtime", (int64_t)GetAdjustedTime())); union { int32_t nBits; @@ -2678,7 +2694,7 @@ int CommandLineRPC(int argc, char *argv[]) string s = params[1].get_str(); Value v; if (!read_string(s, v) || v.type() != array_type) - throw runtime_error("addmultisigaddress: type mismatch "+s); + throw runtime_error("type mismatch "+s); params[1] = v.get_array(); }