1
0
Fork 0
forked from lthn/blockchain

minor fixes over TX_FLAG_SIGNATURE_MODE_SEPARATE

This commit is contained in:
cryptozoidberg 2023-04-18 20:07:33 +02:00
parent 44e22b611d
commit aa8d3207a4
No known key found for this signature in database
GPG key ID: 22DEB97A54C6FDEC
7 changed files with 70 additions and 33 deletions

View file

@ -5175,27 +5175,29 @@ bool blockchain_storage::fill_tx_rpc_details(tx_rpc_extended_info& tei, const tr
//------------------------------------------------------------------
bool blockchain_storage::fill_tx_rpc_inputs(tx_rpc_extended_info& tei, const transaction& tx) const
{
//handle inputs
for (auto in : tx.vin)
{
tei.ins.push_back(tx_in_rpc_entry());
tx_in_rpc_entry& entry_to_fill = tei.ins.back();
if (in.type() == typeid(txin_gen))
{
tei.ins.back().amount = 0;
entry_to_fill.amount = 0;
}
else if (in.type() == typeid(txin_to_key) || in.type() == typeid(txin_htlc))
else if (in.type() == typeid(txin_to_key) || in.type() == typeid(txin_htlc) || in.type() == typeid(txin_zc_input))
{
//TODO: add htlc info
const txin_to_key& tk = get_to_key_input_from_txin_v(in);
tei.ins.back().amount = tk.amount;
tei.ins.back().kimage_or_ms_id = epee::string_tools::pod_to_hex(tk.k_image);
std::vector<txout_ref_v> absolute_offsets = relative_output_offsets_to_absolute(tk.key_offsets);
entry_to_fill.amount = get_amount_from_variant(in);
entry_to_fill.kimage_or_ms_id = epee::string_tools::pod_to_hex(get_key_image_from_txin_v(in));
const std::vector<txout_ref_v>& key_offsets = get_key_offsets_from_txin_v(in);
std::vector<txout_ref_v> absolute_offsets = relative_output_offsets_to_absolute(key_offsets);
for (auto& ao : absolute_offsets)
{
tei.ins.back().global_indexes.push_back(0);
entry_to_fill.global_indexes.push_back(0);
if (ao.type() == typeid(uint64_t))
{
tei.ins.back().global_indexes.back() = boost::get<uint64_t>(ao);
entry_to_fill.global_indexes.back() = boost::get<uint64_t>(ao);
}
else if (ao.type() == typeid(ref_by_id))
{
@ -5211,17 +5213,21 @@ bool blockchain_storage::fill_tx_rpc_inputs(tx_rpc_extended_info& tei, const tra
}
if (in.type() == typeid(txin_htlc))
{
tei.ins.back().htlc_origin = epee::string_tools::buff_to_hex_nodelimer(boost::get<txin_htlc>(in).hltc_origin);
entry_to_fill.htlc_origin = epee::string_tools::buff_to_hex_nodelimer(boost::get<txin_htlc>(in).hltc_origin);
}
//tk.etc_details -> visualize it may be later
}
else if (in.type() == typeid(txin_multisig))
{
txin_multisig& tms = boost::get<txin_multisig>(in);
tei.ins.back().amount = tms.amount;
tei.ins.back().kimage_or_ms_id = epee::string_tools::pod_to_hex(tms.multisig_out_id);
if (tx.signatures.size() >= tei.ins.size())
tei.ins.back().multisig_count = tx.signatures[tei.ins.size() - 1].size();
entry_to_fill.amount = tms.amount;
entry_to_fill.kimage_or_ms_id = epee::string_tools::pod_to_hex(tms.multisig_out_id);
if (tx.signatures.size() >= tei.ins.size() &&
tx.signatures[tei.ins.size() - 1].type() == typeid(NLSAG_sig))
{
entry_to_fill.multisig_count = boost::get<NLSAG_sig>(tx.signatures[tei.ins.size() - 1]).s.size();
}
}
}
return true;

View file

@ -2383,7 +2383,8 @@ namespace currency
//
// proofs (transaction-wise, not pre-input)
//
if (tx.version > TRANSACTION_VERSION_PRE_HF4)
if (tx.version > TRANSACTION_VERSION_PRE_HF4 &&
(append_mode || (flags & TX_FLAG_SIGNATURE_MODE_SEPARATE) == 0))
{
// asset surjection proof
currency::zc_asset_surjection_proof asp{};

View file

@ -919,9 +919,9 @@ namespace currency
pfinalbuff = &deflated_buff;
}
if (ee.service_id == BC_PAYMENT_ID_SERVICE_ID || ee.service_id == BC_OFFERS_SERVICE_ID)
tv.datails_view = *pfinalbuff;
tv.details_view = *pfinalbuff;
else
tv.datails_view = "BINARY DATA";
tv.details_view = "BINARY DATA";
}
return true;
}
@ -929,7 +929,7 @@ namespace currency
{
tv.type = "crypto_checksum";
tv.short_view = std::string("derivation_hash: ") + epee::string_tools::pod_to_hex(ee.derivation_hash);
tv.datails_view = std::string("derivation_hash: ") + epee::string_tools::pod_to_hex(ee.derivation_hash) + "\n"
tv.details_view = std::string("derivation_hash: ") + epee::string_tools::pod_to_hex(ee.derivation_hash) + "\n"
+ "encrypted_key_derivation: " + epee::string_tools::pod_to_hex(ee.encrypted_key_derivation);
return true;
@ -990,14 +990,14 @@ namespace currency
{
tv.type = "attachment_info";
tv.short_view = std::to_string(ee.sz) + " bytes";
tv.datails_view = currency::obj_to_json_str(ee);
tv.details_view = currency::obj_to_json_str(ee);
return true;
}
bool operator()(const extra_alias_entry& ee)
{
tv.type = "alias_info";
tv.short_view = ee.m_alias + "-->" + get_account_address_as_str(ee.m_address);
tv.datails_view = currency::obj_to_json_str(ee);
tv.details_view = currency::obj_to_json_str(ee);
return true;
}
@ -1009,7 +1009,7 @@ namespace currency
{
tv.type = "user_data";
tv.short_view = std::to_string(ee.buff.size()) + " bytes";
tv.datails_view = epee::string_tools::buff_to_hex_nodelimer(ee.buff);
tv.details_view = epee::string_tools::buff_to_hex_nodelimer(ee.buff);
return true;
}
@ -1018,7 +1018,7 @@ namespace currency
tv.type = "extra_padding";
tv.short_view = std::to_string(ee.buff.size()) + " bytes";
if (!ee.buff.empty())
tv.datails_view = epee::string_tools::buff_to_hex_nodelimer(std::string(reinterpret_cast<const char*>(&ee.buff[0]), ee.buff.size()));
tv.details_view = epee::string_tools::buff_to_hex_nodelimer(std::string(reinterpret_cast<const char*>(&ee.buff[0]), ee.buff.size()));
return true;
}
@ -1026,7 +1026,7 @@ namespace currency
{
tv.type = "comment";
tv.short_view = std::to_string(ee.comment.size()) + " bytes(encrypted)";
tv.datails_view = epee::string_tools::buff_to_hex_nodelimer(ee.comment);
tv.details_view = epee::string_tools::buff_to_hex_nodelimer(ee.comment);
return true;
}
@ -1064,7 +1064,7 @@ namespace currency
{
tv.type = "derivation_hint";
tv.short_view = std::to_string(ee.msg.size()) + " bytes";
tv.datails_view = epee::string_tools::buff_to_hex_nodelimer(ee.msg);
tv.details_view = epee::string_tools::buff_to_hex_nodelimer(ee.msg);
return true;
}
@ -1072,7 +1072,7 @@ namespace currency
{
tv.type = "string";
tv.short_view = std::to_string(ee.size()) + " bytes";
tv.datails_view = epee::string_tools::buff_to_hex_nodelimer(ee);
tv.details_view = epee::string_tools::buff_to_hex_nodelimer(ee);
return true;
}
@ -1080,10 +1080,35 @@ namespace currency
{
tv.type = "FLAGS16";
tv.short_view = epee::string_tools::pod_to_hex(dh);
tv.datails_view = epee::string_tools::pod_to_hex(dh);
tv.details_view = epee::string_tools::pod_to_hex(dh);
return true;
}
bool operator()(const zarcanum_tx_data_v1& ztxd)
{
tv.type = "zarcanum_tx_data_v1";
tv.short_view = "fee = " + print_money_brief(ztxd.fee);
tv.details_view = tv.short_view;
return true;
}
bool operator()(const zc_outs_range_proof& rp)
{
tv.type = "zc_outs_range_proof";
// TODO @#@#
//tv.short_view = "outputs_count = " + std::to_string(rp.outputs_count);
return true;
}
bool operator()(const zc_balance_proof& bp)
{
tv.type = "zc_balance_proof";
return true;
}
template<typename t_type>
bool operator()(const t_type& t_t)
{
tv.type = typeid(t_t).name();
return true;
}
};
//------------------------------------------------------------------

View file

@ -1516,7 +1516,7 @@ namespace wallet_public
}
}
bool operator==(const asset_funds& lhs, const asset_funds& rhs)
inline bool operator==(const asset_funds& lhs, const asset_funds& rhs)
{
return lhs.amount == rhs.amount && lhs.asset_id == rhs.asset_id;
}

View file

@ -1085,6 +1085,7 @@ int main(int argc, char* argv[])
GENERATE_AND_PLAY(zarcanum_basic_test);
GENERATE_AND_PLAY(multiassets_basic_test);
GENERATE_AND_PLAY(ionic_swap_basic_test);
GENERATE_AND_PLAY(zarcanum_test_n_inputs_validation);
GENERATE_AND_PLAY(zarcanum_gen_time_balance);
GENERATE_AND_PLAY(zarcanum_txs_with_big_shuffled_decoy_set_shuffled);

View file

@ -42,3 +42,4 @@
#include "isolate_auditable_and_proof.h"
#include "zarcanum_test.h"
#include "multiassets_test.h"
#include "ionic_swap_tests.h"

View file

@ -55,7 +55,7 @@ bool ionic_swap_basic_test::c1(currency::core& c, size_t ev_index, const std::ve
//std::shared_ptr<tools::wallet2> bob_wlt = init_playtime_test_wallet(events, c, BOB_ACC_IDX);
// check passing over the hardfork
CHECK_AND_ASSERT_MES(!c.get_blockchain_storage().is_hardfork_active(ZANO_HARDFORK_04_ZARCANUM), false, "ZANO_HARDFORK_04_ZARCANUM is active");
CHECK_AND_ASSERT_MES(c.get_blockchain_storage().is_hardfork_active(ZANO_HARDFORK_04_ZARCANUM), false, "ZANO_HARDFORK_04_ZARCANUM is active");
currency::account_base alice_acc;
@ -87,6 +87,9 @@ bool ionic_swap_basic_test::c1(currency::core& c, size_t ev_index, const std::ve
miner_wlt->publish_new_asset(adb, destinations, tx, asset_id);
LOG_PRINT_L0("Published new asset: " << asset_id << ", tx_id: " << currency::get_transaction_hash(tx));
currency::transaction res_tx = AUTO_VAL_INIT(res_tx);
miner_wlt->transfer(COIN, alice_wlt->get_account().get_public_address(), res_tx);
r = mine_next_pow_blocks_in_playtime(miner_wlt->get_account().get_public_address(), c, CURRENCY_MINED_MONEY_UNLOCK_WINDOW);
CHECK_AND_ASSERT_MES(r, false, "mine_next_pow_blocks_in_playtime failed");
@ -103,7 +106,7 @@ bool ionic_swap_basic_test::c1(currency::core& c, size_t ev_index, const std::ve
CHECK_AND_ASSERT_MES(it_asset != balances.end() && it_native != balances.end(), false, "Failed to find needed asset in result balances");
CHECK_AND_ASSERT_MES(it_asset->second.total == AMOUNT_ASSETS_TO_TRANSFER_MULTIASSETS_BASIC, false, "Failed to find needed asset in result balances");
CHECK_AND_ASSERT_MES(it_native->second.total == uint64_t(17517226)*COIN, false, "Failed to find needed asset in result balances");
CHECK_AND_ASSERT_MES(it_native->second.total == uint64_t(17517226)*COIN - COIN, false, "Failed to find needed asset in result balances");
uint64_t mined_balance = it_native->second.total;
@ -113,8 +116,8 @@ bool ionic_swap_basic_test::c1(currency::core& c, size_t ev_index, const std::ve
it_asset = balances.find(asset_id);
it_native = balances.find(currency::native_coin_asset_id);
CHECK_AND_ASSERT_MES(it_asset != balances.end(), false, "Failed to find needed asset in result balances");
CHECK_AND_ASSERT_MES(it_native == balances.end(), false, "Failed to find needed asset in result balances");
CHECK_AND_ASSERT_MES(it_asset != balances.end() && it_native != balances.end(), false, "Failed to find needed asset in result balances");
CHECK_AND_ASSERT_MES(it_native->second.total == COIN, false, "Failed to find needed asset in result balances");
CHECK_AND_ASSERT_MES(it_asset->second.total == AMOUNT_ASSETS_TO_TRANSFER_MULTIASSETS_BASIC, false, "Failed to find needed asset in result balances");
const uint64_t assets_to_exchange = 10 * COIN;
@ -126,7 +129,7 @@ bool ionic_swap_basic_test::c1(currency::core& c, size_t ev_index, const std::ve
proposal_details.fee = TESTS_DEFAULT_FEE;
proposal_details.mixins = 10;
proposal_details.from.push_back(view::asset_funds{ asset_id , assets_to_exchange });
proposal_details.to.push_back(view::asset_funds{ currency::null_pkey , native_tokens_to_exchange });
proposal_details.to.push_back(view::asset_funds{ currency::native_coin_asset_id , native_tokens_to_exchange });
tools::wallet_public::ionic_swap_proposal proposal = AUTO_VAL_INIT(proposal);
alice_wlt->create_ionic_swap_proposal(proposal_details, miner_wlt->get_account().get_public_address(), proposal);
@ -140,8 +143,8 @@ bool ionic_swap_basic_test::c1(currency::core& c, size_t ev_index, const std::ve
CHECK_AND_ASSERT_MES(false, false, "proposal actual and proposals decoded mismatch");
}
currency::transaction res_tx = AUTO_VAL_INIT(res_tx);
r = miner_wlt->accept_ionic_swap_proposal(proposal, res_tx);
currency::transaction res_tx2 = AUTO_VAL_INIT(res_tx2);
r = miner_wlt->accept_ionic_swap_proposal(proposal, res_tx2);
CHECK_AND_ASSERT_MES(r, false, "Failed to accept ionic proposal");
r = mine_next_pow_blocks_in_playtime(miner_wlt->get_account().get_public_address(), c, CURRENCY_MINED_MONEY_UNLOCK_WINDOW);