out.push_back(Pair("addresses", a));
}
-void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry)
-{
- entry.push_back(Pair("txid", tx.GetHash().GetHex()));
- entry.push_back(Pair("version", tx.nVersion));
- entry.push_back(Pair("locktime", (int64_t)tx.nLockTime));
- Array vin;
- BOOST_FOREACH(const CTxIn& txin, tx.vin) {
- Object in;
- if (tx.IsCoinBase())
- in.push_back(Pair("coinbase", HexStr(txin.scriptSig.begin(), txin.scriptSig.end())));
- else {
- in.push_back(Pair("txid", txin.prevout.hash.GetHex()));
- in.push_back(Pair("vout", (int64_t)txin.prevout.n));
- Object o;
- o.push_back(Pair("asm", txin.scriptSig.ToString()));
- o.push_back(Pair("hex", HexStr(txin.scriptSig.begin(), txin.scriptSig.end())));
- in.push_back(Pair("scriptSig", o));
- }
- in.push_back(Pair("sequence", (int64_t)txin.nSequence));
- vin.push_back(in);
- }
- entry.push_back(Pair("vin", vin));
- Array vout;
- for (unsigned int i = 0; i < tx.vout.size(); i++) {
- const CTxOut& txout = tx.vout[i];
- Object out;
- out.push_back(Pair("value", ValueFromAmount(txout.nValue)));
- out.push_back(Pair("n", (int64_t)i));
- Object o;
- ScriptPubKeyToJSON(txout.scriptPubKey, o, true);
- out.push_back(Pair("scriptPubKey", o));
- vout.push_back(out);
- }
- entry.push_back(Pair("vout", vout));
+Array TxJoinSplitToJSON(const CTransaction& tx) {
Array vjoinsplit;
for (unsigned int i = 0; i < tx.vjoinsplit.size(); i++) {
const JSDescription& jsdescription = tx.vjoinsplit[i];
{
Array nullifiers;
- BOOST_FOREACH(const uint256 serial, jsdescription.nullifiers) {
- nullifiers.push_back(serial.GetHex());
+ BOOST_FOREACH(const uint256 nf, jsdescription.nullifiers) {
+ nullifiers.push_back(nf.GetHex());
}
joinsplit.push_back(Pair("nullifiers", nullifiers));
}
joinsplit.push_back(Pair("vpub_old", ValueFromAmount(jsdescription.vpub_old)));
joinsplit.push_back(Pair("vpub_new", ValueFromAmount(jsdescription.vpub_new)));
- // TODO: #808
- uint256 pubKeyHash;
- joinsplit.push_back(Pair("valid", jsdescription.Verify(*pzcashParams, pubKeyHash)));
-
vjoinsplit.push_back(joinsplit);
}
+ return vjoinsplit;
+}
+
+uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime);
+
+void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry)
+{
+ entry.push_back(Pair("txid", tx.GetHash().GetHex()));
+ entry.push_back(Pair("version", tx.nVersion));
+ entry.push_back(Pair("locktime", (int64_t)tx.nLockTime));
+ Array vin;
+ BOOST_FOREACH(const CTxIn& txin, tx.vin) {
+ Object in;
+ if (tx.IsCoinBase())
+ in.push_back(Pair("coinbase", HexStr(txin.scriptSig.begin(), txin.scriptSig.end())));
+ else {
+ in.push_back(Pair("txid", txin.prevout.hash.GetHex()));
+ in.push_back(Pair("vout", (int64_t)txin.prevout.n));
+ Object o;
+ o.push_back(Pair("asm", txin.scriptSig.ToString()));
+ o.push_back(Pair("hex", HexStr(txin.scriptSig.begin(), txin.scriptSig.end())));
+ in.push_back(Pair("scriptSig", o));
+ }
+ in.push_back(Pair("sequence", (int64_t)txin.nSequence));
+ vin.push_back(in);
+ }
+ entry.push_back(Pair("vin", vin));
+ Array vout;
+ BlockMap::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock());
+ CBlockIndex *pindex = it->second;
+ uint64_t interest;
+ for (unsigned int i = 0; i < tx.vout.size(); i++) {
+ const CTxOut& txout = tx.vout[i];
+ Object out;
+ out.push_back(Pair("value", ValueFromAmount(txout.nValue)));
+ if ( pindex != 0 && tx.nLockTime != 0 )
+ {
+ interest = komodo_interest(pindex->nHeight,txout.nValue,tx.nLockTime,pindex->nTime);
+ //fprintf(stderr,"TxtoJSON interest %llu %.8f\n",(long long)interest,(double)interest/COIN);
+ out.push_back(Pair("interest", ValueFromAmount(interest)));
+ }
+ out.push_back(Pair("n", (int64_t)i));
+ Object o;
+ ScriptPubKeyToJSON(txout.scriptPubKey, o, true);
+ out.push_back(Pair("scriptPubKey", o));
+ vout.push_back(out);
+ }
+ entry.push_back(Pair("vout", vout));
+ Array vjoinsplit = TxJoinSplitToJSON(tx);
entry.push_back(Pair("vjoinsplit", vjoinsplit));
if (!hashBlock.IsNull()) {