moneroexamples 5 years ago
parent 528363ce8e
commit 18b3bf802d

@ -11,7 +11,8 @@
"_comment" : "if paths are empty, default Monero paths will be used",
"mainnet" : "",
"testnet" : "",
"stagenet" : ""
"stagenet" : "",
"stagenet2" : "/home/mwo2/stagenet/node_01/stagenet/lmdb"
},
"database" :
{

File diff suppressed because one or more lines are too long

@ -1141,37 +1141,74 @@ CurrentBlockchainStatus::construct_output_rct_field(
string rtc_mask(64, '0');
string rtc_amount(64, '0');
//if (random_output_tx.version == 1)
//{
//rtc_outpk = "";
//rtc_mask = "";
//rtc_amount = "";
//}
//else
//{
//if (random_output_tx.rct_signatures.type > 0)
//{
//rtc_outpk = pod_to_hex(random_output_tx.rct_signatures
//.outPk[output_idx_in_tx].mask);
//rtc_mask = pod_to_hex(random_output_tx.rct_signatures
//.ecdhInfo[output_idx_in_tx].mask);
//rtc_amount = pod_to_hex(random_output_tx.rct_signatures
//.ecdhInfo[output_idx_in_tx].amount);
//}
//if (random_output_tx.rct_signatures.type == 0)
//{
//rtc_outpk = "coinbase";
//}
//else if (random_output_tx.rct_signatures.type == 4)
//{
//rtc_amount = rtc_amount.substr(0,16);
//}
//}
//cout << "random_outs : " << rtc_outpk << ","
//<< rtc_mask << ","<< rtc_amount << endl;
if (random_output_tx.version > 1 && !is_coinbase(random_output_tx))
{
rtc_outpk = pod_to_hex(random_output_tx.rct_signatures
.outPk[output_idx_in_tx].mask);
.outPk[output_idx_in_tx].mask);
rtc_mask = pod_to_hex(random_output_tx.rct_signatures
.ecdhInfo[output_idx_in_tx].mask);
rtc_amount = pod_to_hex(random_output_tx.rct_signatures
.ecdhInfo[output_idx_in_tx].amount);
}
else
{
// for non ringct txs, we need to take it rct amount commitment
// and sent to the frontend. the mask is zero mask for those,
// as frontend will produce identy mask autmatically
// for non-ringct outputs
//// for non ringct txs, we need to take it rct amount commitment
//// and sent to the frontend. the mask is zero mask for those,
//// as frontend will produce identy mask autmatically
//// for non-ringct outputs
output_data_t od = get_output_key(out_amount, global_amount_index);
rtc_outpk = pod_to_hex(od.commitment);
if (is_coinbase(random_output_tx))
{
// commenting this out. think its not needed.
// as this function provides keys for mixin outputs
// not the ones we actually spend.
// ringct coinbase txs are special. they have identity mask.
// as suggested by this code:
// https://github.com/monero-project/monero/blob/eacf2124b6822d088199179b18d4587404408e0f/src/wallet/wallet2.cpp#L893
// https://github.com/monero-project/monero/blob/master/src/blockchain_db/blockchain_db.cpp#L100
// rtc_mask = pod_to_hex(rct::identity());
}
//if (is_coinbase(random_output_tx))
//{
//// commenting this out. think its not needed.
//// as this function provides keys for mixin outputs
//// not the ones we actually spend.
//// ringct coinbase txs are special. they have identity mask.
//// as suggested by this code:
//// https://github.com/monero-project/monero/blob/eacf2124b6822d088199179b18d4587404408e0f/src/wallet/wallet2.cpp#L893
//// https://github.com/monero-project/monero/blob/master/src/blockchain_db/blockchain_db.cpp#L100
//// rtc_mask = pod_to_hex(rct::identity());
//}
}

@ -618,84 +618,115 @@ OpenMoneroRequests::get_unspent_outs(
continue;
}
// if (!bool {tx.coinbase})
// {
// continue;
// }
vector<XmrOutput> outs;
if (xmr_accounts->select_for_tx(tx.id.data, outs))
if (!xmr_accounts->select_for_tx(tx.id.data, outs))
{
for (XmrOutput &out: outs)
{
// skip outputs considered as dust
if (out.amount < dust_threshold)
{
continue;
}
// need to check for rct commintment
// coinbase ringct txs dont have
// rct filed in them. Thus
// we need to make them.
uint64_t global_amount_index = out.global_index;
continue;
}
string rct = out.get_rct();
for (XmrOutput &out: outs)
{
// skip outputs considered as dust
if (out.amount < dust_threshold)
{
continue;
}
// coinbase rct txs require speciall treatment
if (tx.coinbase && tx.is_rct)
{
uint64_t amount = (tx.is_rct ? 0 : out.amount);
// need to check for rct commintment
// coinbase ringct txs dont have
// rct filed in them. Thus
// we need to make them.
output_data_t od =
current_bc_status->get_output_key(
amount, global_amount_index);
uint64_t global_amount_index = out.global_index;
string rtc_outpk = pod_to_hex(od.commitment);
string rtc_mask = pod_to_hex(rct::identity());
string rtc_amount(64, '0');
// default case. it will cover
// rct types 1 (Full) and 2 (Simple)
// rct types explained here:
// https://monero.stackexchange.com/questions/3348/what-are-3-types-of-ring-ct-transactions
string rct = out.get_rct();
rct = rtc_outpk + rtc_mask + rtc_amount;
}
// based on
// https://github.com/mymonero/mymonero-app-js/issues/277#issuecomment-469395825
json j_out{
{"amount" , std::to_string(out.amount)},
{"public_key" , out.out_pub_key},
{"index" , out.out_index},
{"global_index" , out.global_index},
{"rct" , rct},
{"tx_id" , out.tx_id},
{"tx_hash" , tx.hash},
{"tx_prefix_hash" , tx.prefix_hash},
{"tx_pub_key" , tx.tx_pub_key},
{"timestamp" , static_cast<uint64_t>(
out.timestamp*1e3)},
{"height" , tx.height},
{"spend_key_images", json::array()}
};
if (!tx.is_rct)
{
// point 1: null/undefined/empty:
// non-RingCT output (i.e, from version 1 tx)
// covers all pre-ringct outputs
rct = "";
}
else
{
// for RingCT:
if (tx.rct_type == 0)
{
// coinbase rct txs require speciall treatment
// point 2: string "coinbase" (length 8):
// RingCT coinbase output
rct = "coinbase";
}
else if (tx.rct_type == 3)
{
// point 3: string length 192: non-coinbase RingCT
// version 1 output with 256-bit amount and mask
// rct type 3 is Booletproof
rct = out.rct_outpk + out.rct_mask + out.rct_amount;
}
else if (tx.rct_type == 4)
{
// point 4 string length 80:
// non-coinbase RingCT version 2
// output 64 bit amount
// rct type 4 is Booletproof2
rct = out.rct_outpk + out.rct_amount.substr(0,16);
}
}
vector<XmrInput> ins;
//cout << "tx hash: " << tx.hash << ", rtc: " << rct
// << ", rtc size: " << rct.size()
// << ", decrypted mask: " << out.rct_mask
// << endl;
json j_out{
{"amount" , std::to_string(out.amount)},
{"public_key" , out.out_pub_key},
{"index" , out.out_index},
{"global_index" , out.global_index},
{"rct" , rct},
{"tx_id" , out.tx_id},
{"tx_hash" , tx.hash},
{"tx_prefix_hash" , tx.prefix_hash},
{"tx_pub_key" , tx.tx_pub_key},
{"timestamp" , static_cast<uint64_t>(
out.timestamp*1e3)},
{"height" , tx.height},
{"spend_key_images", json::array()}
};
vector<XmrInput> ins;
if (xmr_accounts->select_inputs_for_out(
out.id.data, ins))
{
json& j_ins = j_out["spend_key_images"];
if (xmr_accounts->select_inputs_for_out(
out.id.data, ins))
for (XmrInput& in: ins)
{
json& j_ins = j_out["spend_key_images"];
for (XmrInput& in: ins)
{
j_ins.push_back(in.key_image);
}
j_ins.push_back(in.key_image);
}
}
j_outputs.push_back(j_out);
total_outputs_amount += out.amount;
j_outputs.push_back(j_out);
} //for (XmrOutput &out: outs)
total_outputs_amount += out.amount;
} // if (xmr_accounts->select_outputs_for_tx(tx.id, outs))
} //for (XmrOutput &out: outs)
} // for (XmrTransaction& tx: txs)
@ -711,7 +742,6 @@ OpenMoneroRequests::get_unspent_outs(
j_response["per_byte_fee"] = current_bc_status
->get_dynamic_base_fee_estimate();
} // if (current_bc_status->search_thread_exist(xmr_address))
else
{
@ -814,6 +844,9 @@ OpenMoneroRequests::get_random_outs(
+ std::get<1>(rct_field) // rct_mask
+ std::get<2>(rct_field); // rct_amount
json out_details {
{"global_index", out.global_amount_index},
{"public_key" , pod_to_hex(out.out_key)},
@ -1713,7 +1746,7 @@ OpenMoneroRequests::get_version(
{"last_git_commit_hash", string {GIT_COMMIT_HASH}},
{"last_git_commit_date", string {GIT_COMMIT_DATETIME}},
{"git_branch_name" , string {GIT_BRANCH_NAME}},
{"monero_version_full" , string {"MONERO_VERSION_FULL"}},
{"monero_version_full" , string {MONERO_VERSION_FULL}},
{"api" , OPENMONERO_RPC_VERSION},
{"testnet" , current_bc_status->get_bc_setup().net_type
== network_type::TESTNET},

@ -1 +1 @@
Subproject commit f8e2162dcb861223f99cf06792b9d73294db739a
Subproject commit 939885dca443d994c0fc236ee7f292b6b11560c4
Loading…
Cancel
Save