Extend gettransaction RPC call result with hash of transaction metadata. 6/head
authorCryptoManiac <balthazar@yandex.ru>
Wed, 19 Feb 2014 21:45:22 +0000 (01:45 +0400)
committerCryptoManiac <balthazar@yandex.ru>
Wed, 19 Feb 2014 21:45:22 +0000 (01:45 +0400)
src/main.h
src/rpcrawtransaction.cpp
src/rpcwallet.cpp
src/script.h

index 0be23cc..f19bd87 100644 (file)
@@ -465,6 +465,11 @@ public:
         return SerializeHash(*this);
     }
 
+    uint256 GetMetaHash() const
+    {
+        return SignatureHash(CScript(), *this, 0, SIGHASH_ALL);
+    }
+
     bool IsFinal(int nBlockHeight=0, int64 nBlockTime=0) const
     {
         // Time based nLockTime implemented in 0.1.6
index 4a164ca..e159b33 100644 (file)
@@ -47,6 +47,7 @@ void ScriptPubKeyToJSON(const CScript& scriptPubKey, Object& out, bool fIncludeH
 void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry)
 {
     entry.push_back(Pair("txid", tx.GetHash().GetHex()));
+    entry.push_back(Pair("metahash", tx.GetMetaHash().GetHex()));
     entry.push_back(Pair("version", tx.nVersion));
     entry.push_back(Pair("time", (boost::int64_t)tx.nTime));
     entry.push_back(Pair("locktime", (boost::int64_t)tx.nLockTime));
index d1d4eee..c6a4302 100644 (file)
@@ -45,7 +45,9 @@ void WalletTxToJSON(const CWalletTx& wtx, Object& entry)
         entry.push_back(Pair("blocktime", (boost::int64_t)(mapBlockIndex[wtx.hashBlock]->nTime)));
     }
     uint256 hash = wtx.GetHash();
+    uint256 metahash = wtx.GetMetaHash();
     entry.push_back(Pair("txid", hash.GetHex()));
+    entry.push_back(Pair("metahash", metahash.GetHex()));
     Array conflicts;
     BOOST_FOREACH(const uint256& conflict, wtx.GetConflicts())
         conflicts.push_back(conflict.GetHex());
index 8965299..13ecf4f 100644 (file)
@@ -660,6 +660,8 @@ public:
 bool IsCanonicalPubKey(const std::vector<unsigned char> &vchPubKey);
 bool IsCanonicalSignature(const std::vector<unsigned char> &vchSig);
 
+uint256 SignatureHash(CScript scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType);
+
 bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript& script, const CTransaction& txTo, unsigned int nIn, bool fStrictEncodings, int nHashType);
 bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<std::vector<unsigned char> >& vSolutionsRet);
 int ScriptSigArgsExpected(txnouttype t, const std::vector<std::vector<unsigned char> >& vSolutions);