remove unused conversions.

This commit is contained in:
Christopher Jeffrey 2014-09-25 15:33:37 -07:00
parent c6ca9d5dbf
commit 27a137022c
1 changed files with 0 additions and 149 deletions

View File

@ -1299,155 +1299,6 @@ ctx_to_js(const CTransaction& tx, uint256 hashBlock, Local<Object> entry) {
}
}
#if 0
static inline void
hex_to_ctx(string strHex, const CTransaction& tx) {
CDataStream stream(ParseHex(strHex), SER_NETWORK, PROTOCOL_VERSION);
// CTransaction tx;
stream >> tx;
}
static inline void
js_to_ctx(Local<Object> entry, const CTransaction& tx, uint256 hashBlock) {
String::Utf8Value tx_hex_(entry->Get(NanNew<String>("hex"))->ToString());
std::string tx_hex = std::string(*txHex_);
if (tx_hex[1] != 'x') {
tx_hex = "0x" + tx_hex;
}
// std::string tx_hex = data->tx_hex;
// uint256 hash(tx_hex);
std::string strHex(tx_hex);
// CTransaction tx;
hex_to_ctx(strHex, tx);
}
static inline void
js_to_ctx(Local<Object> entry, const CTransaction& tx, uint256 hashBlock) {
// entry->Set(NanNew<String>("hex"), NanNew<String>(strHex));
entry->Set(NanNew<String>("txid"), NanNew<String>(tx.GetHash().GetHex()));
entry->Set(NanNew<String>("version"), NanNew<Number>(tx.nVersion));
entry->Set(NanNew<String>("locktime"), NanNew<Number>(tx.nLockTime));
Local<Array> vin = NanNew<Array>();
int vi = 0;
BOOST_FOREACH(const CTxIn& txin, tx.vin) {
Local<Object> in = NanNew<Object>();
if (tx.IsCoinBase()) {
in->Set(NanNew<String>("coinbase"), NanNew<String>(HexStr(txin.scriptSig.begin(), txin.scriptSig.end())));
} else {
in->Set(NanNew<String>("txid"), NanNew<String>(txin.prevout.hash.GetHex()));
in->Set(NanNew<String>("vout"), NanNew<Number>((boost::int64_t)txin.prevout.n));
Local<Object> o = NanNew<Object>();
o->Set(NanNew<String>("asm"), NanNew<String>(txin.scriptSig.ToString()));
o->Set(NanNew<String>("hex"), NanNew<String>(HexStr(txin.scriptSig.begin(), txin.scriptSig.end())));
in->Set(NanNew<String>("scriptSig"), o);
}
in->Set(NanNew<String>("sequence"), NanNew<Number>((boost::int64_t)txin.nSequence));
vin->Set(vi, in);
vi++;
}
entry->Set(NanNew<String>("vin"), vin);
Local<Array> vout = NanNew<Array>();
for (unsigned int vo = 0; vo < tx.vout.size(); vo++) {
const CTxOut& txout = tx.vout[vo];
Local<Object> out = NanNew<Object>();
out->Set(NanNew<String>("value"), NanNew<Number>(txout.nValue));
out->Set(NanNew<String>("n"), NanNew<Number>((boost::int64_t)vo));
Local<Object> o = NanNew<Object>();
{
const CScript& scriptPubKey = txout.scriptPubKey;
Local<Object> out = o;
bool fIncludeHex = true;
txnouttype type;
vector<CTxDestination> addresses;
int nRequired;
out->Set(NanNew<String>("asm"), NanNew<String>(scriptPubKey.ToString()));
if (fIncludeHex) {
out->Set(NanNew<String>("hex"), NanNew<String>(HexStr(scriptPubKey.begin(), scriptPubKey.end())));
}
if (!ExtractDestinations(scriptPubKey, type, addresses, nRequired)) {
out->Set(NanNew<String>("type"), NanNew<String>(GetTxnOutputType(type)));
} else {
out->Set(NanNew<String>("reqSigs"), NanNew<Number>(nRequired));
out->Set(NanNew<String>("type"), NanNew<String>(GetTxnOutputType(type)));
Local<Array> a = NanNew<Array>();
int ai = 0;
BOOST_FOREACH(const CTxDestination& addr, addresses) {
a->Set(ai, NanNew<String>(CBitcoinAddress(addr).ToString()));
ai++;
}
out->Set(NanNew<String>("addresses"), a);
}
}
out->Set(NanNew<String>("scriptPubKey"), o);
vout->Set(vo, out);
}
entry->Set(NanNew<String>("vout"), vout);
if (hashBlock != 0) {
entry->Set(NanNew<String>("blockhash"), NanNew<String>(hashBlock.GetHex()));
map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hashBlock);
if (mi != mapBlockIndex.end() && (*mi).second) {
CBlockIndex* pindex = (*mi).second;
if (chainActive.Contains(pindex)) {
entry->Set(NanNew<String>("confirmations"),
NanNew<Number>(1 + chainActive.Height() - pindex->nHeight));
entry->Set(NanNew<String>("time"), NanNew<Number>((boost::int64_t)pindex->nTime));
entry->Set(NanNew<String>("blocktime"), NanNew<Number>((boost::int64_t)pindex->nTime));
} else {
entry->Set(NanNew<String>("confirmations"), NanNew<Number>(0));
}
}
}
CTransaction rawTx;
BOOST_FOREACH(const Value& input, inputs) {
const Object& o = input.get_obj();
uint256 txid = ParseHashO(o, "txid");
const Value& vout_v = find_value(o, "vout");
if (vout_v.type() != int_type)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, missing vout key");
int nOutput = vout_v.get_int();
if (nOutput < 0)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, vout must be positive");
CTxIn in(COutPoint(txid, nOutput));
rawTx.vin.push_back(in);
}
set<CBitcoinAddress> setAddress;
BOOST_FOREACH(const Pair& s, sendTo) {
CBitcoinAddress address(s.name_);
if (!address.IsValid())
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("Invalid Bitcoin address: ")+s.name_);
if (setAddress.count(address))
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, duplicated address: ")+s.name_);
setAddress.insert(address);
CScript scriptPubKey;
scriptPubKey.SetDestination(address.Get());
int64_t nAmount = AmountFromValue(s.value_);
CTxOut out(nAmount, scriptPubKey);
rawTx.vout.push_back(out);
}
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
ss << rawTx;
return HexStr(ss.begin(), ss.end());
}
#endif
/**
* Init
*/