moneroexamples 5 years ago
parent 528363ce8e
commit 18b3bf802d

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

File diff suppressed because one or more lines are too long

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

@ -618,15 +618,14 @@ OpenMoneroRequests::get_unspent_outs(
continue; continue;
} }
// if (!bool {tx.coinbase})
// {
// continue;
// }
vector<XmrOutput> outs; vector<XmrOutput> outs;
if (xmr_accounts->select_for_tx(tx.id.data, outs)) if (!xmr_accounts->select_for_tx(tx.id.data, outs))
{ {
continue;
}
for (XmrOutput &out: outs) for (XmrOutput &out: outs)
{ {
// skip outputs considered as dust // skip outputs considered as dust
@ -642,24 +641,58 @@ OpenMoneroRequests::get_unspent_outs(
uint64_t global_amount_index = out.global_index; uint64_t global_amount_index = out.global_index;
// 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(); string rct = out.get_rct();
// coinbase rct txs require speciall treatment // based on
if (tx.coinbase && tx.is_rct) // https://github.com/mymonero/mymonero-app-js/issues/277#issuecomment-469395825
if (!tx.is_rct)
{ {
uint64_t amount = (tx.is_rct ? 0 : out.amount); // 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
output_data_t od = rct = "coinbase";
current_bc_status->get_output_key( }
amount, global_amount_index); 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
string rtc_outpk = pod_to_hex(od.commitment); rct = out.rct_outpk + out.rct_mask + out.rct_amount;
string rtc_mask = pod_to_hex(rct::identity()); }
string rtc_amount(64, '0'); 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 = rtc_outpk + rtc_mask + rtc_amount; rct = out.rct_outpk + out.rct_amount.substr(0,16);
}
} }
//cout << "tx hash: " << tx.hash << ", rtc: " << rct
// << ", rtc size: " << rct.size()
// << ", decrypted mask: " << out.rct_mask
// << endl;
json j_out{ json j_out{
{"amount" , std::to_string(out.amount)}, {"amount" , std::to_string(out.amount)},
{"public_key" , out.out_pub_key}, {"public_key" , out.out_pub_key},
@ -695,8 +728,6 @@ OpenMoneroRequests::get_unspent_outs(
} //for (XmrOutput &out: outs) } //for (XmrOutput &out: outs)
} // if (xmr_accounts->select_outputs_for_tx(tx.id, outs))
} // for (XmrTransaction& tx: txs) } // for (XmrTransaction& tx: txs)
} // if (xmr_accounts->select_txs(acc.id, txs)) } // if (xmr_accounts->select_txs(acc.id, txs))
@ -711,7 +742,6 @@ OpenMoneroRequests::get_unspent_outs(
j_response["per_byte_fee"] = current_bc_status j_response["per_byte_fee"] = current_bc_status
->get_dynamic_base_fee_estimate(); ->get_dynamic_base_fee_estimate();
} // if (current_bc_status->search_thread_exist(xmr_address)) } // if (current_bc_status->search_thread_exist(xmr_address))
else else
{ {
@ -814,6 +844,9 @@ OpenMoneroRequests::get_random_outs(
+ std::get<1>(rct_field) // rct_mask + std::get<1>(rct_field) // rct_mask
+ std::get<2>(rct_field); // rct_amount + std::get<2>(rct_field); // rct_amount
json out_details { json out_details {
{"global_index", out.global_amount_index}, {"global_index", out.global_amount_index},
{"public_key" , pod_to_hex(out.out_key)}, {"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_hash", string {GIT_COMMIT_HASH}},
{"last_git_commit_date", string {GIT_COMMIT_DATETIME}}, {"last_git_commit_date", string {GIT_COMMIT_DATETIME}},
{"git_branch_name" , string {GIT_BRANCH_NAME}}, {"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}, {"api" , OPENMONERO_RPC_VERSION},
{"testnet" , current_bc_status->get_bc_setup().net_type {"testnet" , current_bc_status->get_bc_setup().net_type
== network_type::TESTNET}, == network_type::TESTNET},

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