MultiOutputsRingCT test added

new_rpc
moneroexamples 5 years ago
parent a4a37d0b24
commit b7827081ca

@ -75,7 +75,7 @@ public:
->identify(tx, tx_pub_key);
auto pay_id = identifier.template get<IntegratedPaymentID>()
->get_id();
->get();
// we have pay_id. it can be crypto::hash8 or crypto:hash
// so naw we need to perform comparison of the pay_id found

@ -26,7 +26,7 @@ Output::identify(transaction const& tx,
if (!additional_tx_pub_keys.empty())
{
additional_derivations.reserve(additional_tx_pub_keys.size());
additional_derivations.resize(additional_tx_pub_keys.size());
for (size_t i = 0; i < additional_tx_pub_keys.size(); ++i)
{
@ -62,6 +62,11 @@ Output::identify(transaction const& tx,
get_address()->address.m_spend_public_key,
generated_tx_pubkey);
// cout << pod_to_hex(derivation) << ", " << i << ", "
// << pod_to_hex(get_address()->address.m_spend_public_key) << ", "
// << pod_to_hex(txout_key.key) << " == "
// << pod_to_hex(generated_tx_pubkey) << '\n' << '\n';
// check if generated public key matches the current output's key
bool mine_output = (txout_key.key == generated_tx_pubkey);
@ -75,6 +80,7 @@ Output::identify(transaction const& tx,
get_address()->address.m_spend_public_key,
generated_tx_pubkey);
mine_output = (txout_key.key == generated_tx_pubkey);
with_additional = true;
@ -87,10 +93,6 @@ Output::identify(transaction const& tx,
rct::key rtc_mask {0};
rct::key rtc_amount {0};
// use primary derivation or the one from additional public keys
derivation = !with_additional ? derivation
: additional_derivations[i];
// if mine output has RingCT, i.e., tx version is 2
// need to decode its amount. otherwise its zero.
if (mine_output && tx.version == 2)
@ -121,10 +123,11 @@ Output::identify(transaction const& tx,
.ecdhInfo[i].mask;
auto r = decode_ringct(tx.rct_signatures,
derivation,
i,
mask,
rct_amount_val);
!with_additional ? derivation
: additional_derivations[i],
i,
mask,
rct_amount_val);
if (!r)
{

@ -80,6 +80,8 @@ public:
rct::key rtc_outpk;
rct::key rtc_mask;
rct::key rtc_amount;
friend std::ostream& operator<<(std::ostream& os, info const& _info);
};
protected:
@ -221,7 +223,7 @@ public:
p_id, tx_pub_key, *get_viewkey());
}
inline auto get_id() const {return payment_id;}
inline auto get() const {return payment_id;}
private:
HashT payment_id {};
@ -298,4 +300,14 @@ calc_total_xmr(T&& infos)
return total_xmr;
}
inline std::ostream&
operator<<(std::ostream& os, xmreg::Output::info const& _info)
{
return os << _info.idx_in_tx << ", "
<< pod_to_hex(_info.pub_key) << ", "
<< _info.amount;
}
}

@ -44,6 +44,7 @@ parse_str_secret_key(const string& key_str, T& secret_key)
template bool parse_str_secret_key<crypto::secret_key>(const string& key_str, crypto::secret_key& secret_key);
template bool parse_str_secret_key<crypto::public_key>(const string& key_str, crypto::public_key& secret_key);
template bool parse_str_secret_key<crypto::hash>(const string& key_str, crypto::hash& secret_key);
template bool parse_str_secret_key<crypto::hash8>(const string& key_str, crypto::hash8& secret_key);
/**
* Get transaction tx using given tx hash. Hash is represent as string here,

@ -23,6 +23,10 @@ JsonTx::init()
{
ntype = cryptonote::network_type {jtx["nettype"]};
hex_to_pod(jtx["payment_id"], payment_id);
hex_to_pod(jtx["payment_id8"], payment_id8);
hex_to_pod(jtx["payment_id8e"], payment_id8e);
addr_and_viewkey_from_string(
jtx["sender"]["address"], jtx["sender"]["viewkey"], \
ntype, sender.address, sender.viewkey);
@ -31,6 +35,7 @@ JsonTx::init()
sender.amount = jtx["sender"]["amount"];
sender.change = jtx["sender"]["change"];
sender.ntype = ntype;
populate_outputs(jtx["sender"]["outputs"], sender.outputs);
@ -48,6 +53,9 @@ JsonTx::init()
recipients.back().amount = jrecpient["amount"];
recipients.back().is_subaddress = jrecpient["is_subaddress"];
recipients.back().ntype = ntype;
populate_outputs(jrecpient["outputs"], recipients.back().outputs);
}

@ -29,17 +29,33 @@ public:
address_parse_info address {};
secret_key viewkey {};
secret_key spendkey {};
bool is_subaddress {false};
network_type ntype;
uint64_t amount {0};
uint64_t change {0};
vector<output> outputs;
inline string
address_str() const
{
return get_account_address_as_str(ntype,
is_subaddress,
address.address);
}
friend std::ostream&
operator<<(std::ostream& os, account const& _account);
};
json jtx;
transaction tx;
crypto::hash tx_hash; \
crypto::hash tx_prefix_hash;
crypto::hash tx_hash {0}; \
crypto::hash tx_prefix_hash {0};
crypto::public_key tx_pub_key;
crypto::hash payment_id {0};
crypto::hash8 payment_id8 {0};
crypto::hash8 payment_id8e {0};
string jpath;
network_type ntype;
@ -57,6 +73,12 @@ private:
};
inline std::ostream&
operator<<(std::ostream& os, JsonTx::account const& _account)
{
return os << _account.address_str();
}
bool
check_and_adjust_path(string& in_path);
@ -64,7 +86,6 @@ check_and_adjust_path(string& in_path);
boost::optional<JsonTx>
construct_jsontx(string tx_hash);
}

@ -0,0 +1,7 @@
# Test transaction data
Json files containing testing transactions data for unit tests.
The were obtained using `Full ring member txs as hex` option in the onion explorer
running wiht `--enable-as-hex` flag.
The wallet information were manual entered.

@ -9,7 +9,7 @@
"nettype": 2,
"payment_id": "0000000000000000000000000000000000000000000000000000000000000000",
"payment_id8": "0000000000000000",
"payment_id8e": "placeholder for decrypted value",
"payment_id8e": "0000000000000000",
"rct_type": 0,
"recipient": [{
"_comment": "monerowalletstagenet3, coinbase tx",

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save