forked from lthn/blockchain
fixed bug in constract_tx regarding inputs mapping
This commit is contained in:
parent
8a54924407
commit
b3daf9aa08
4 changed files with 16 additions and 11 deletions
|
|
@ -2082,10 +2082,12 @@ namespace currency
|
|||
//size_t in_context_index = 0;
|
||||
crypto::scalar_t local_blinding_masks_sum = 0; // ZC only
|
||||
r = false;
|
||||
for (size_t i = 0; i != sources.size(); i++)
|
||||
for (size_t i_ = 0; i_ != sources.size(); i_++)
|
||||
{
|
||||
const tx_source_entry& source_entry = sources[inputs_mapping[i]];
|
||||
crypto::hash tx_hash_for_signature = prepare_prefix_hash_for_sign(tx, i + input_starter_index, tx_prefix_hash);
|
||||
size_t i_mapped = inputs_mapping[i_];
|
||||
|
||||
const tx_source_entry& source_entry = sources[i_mapped];
|
||||
crypto::hash tx_hash_for_signature = prepare_prefix_hash_for_sign(tx, i_ + input_starter_index, tx_prefix_hash);
|
||||
CHECK_AND_ASSERT_MES(tx_hash_for_signature != null_hash, false, "prepare_prefix_hash_for_sign failed");
|
||||
std::stringstream ss_ring_s;
|
||||
|
||||
|
|
@ -2093,14 +2095,14 @@ namespace currency
|
|||
{
|
||||
// ZC
|
||||
// blinding_masks_sum is supposed to be sum(mask of all tx output) - sum(masks of all pseudo out commitments)
|
||||
r = generate_ZC_sig(tx_hash_for_signature, i + input_starter_index, source_entry, in_contexts[i], sender_account_keys, blinding_masks_sum, flags,
|
||||
local_blinding_masks_sum, tx, i + 1 == sources.size());
|
||||
r = generate_ZC_sig(tx_hash_for_signature, i_ + input_starter_index, source_entry, in_contexts[i_mapped], sender_account_keys, blinding_masks_sum, flags,
|
||||
local_blinding_masks_sum, tx, i_ + 1 == sources.size());
|
||||
CHECK_AND_ASSERT_MES(r, false, "generate_ZC_sigs failed");
|
||||
}
|
||||
else
|
||||
{
|
||||
// NLSAG
|
||||
r = generate_NLSAG_sig(tx_hash_for_signature, tx_prefix_hash, i + input_starter_index, source_entry, sender_account_keys, in_contexts[i], txkey, flags, tx, &ss_ring_s);
|
||||
r = generate_NLSAG_sig(tx_hash_for_signature, tx_prefix_hash, i_ + input_starter_index, source_entry, sender_account_keys, in_contexts[i_mapped], txkey, flags, tx, &ss_ring_s);
|
||||
CHECK_AND_ASSERT_MES(r, false, "generate_NLSAG_sig failed");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1061,7 +1061,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
GENERATE_AND_PLAY(zarcanum_basic_test);
|
||||
GENERATE_AND_PLAY(multiassets_basic_test);
|
||||
|
||||
|
||||
|
||||
|
||||
// GENERATE_AND_PLAY(gen_block_reward);
|
||||
|
|
|
|||
|
|
@ -16,13 +16,14 @@
|
|||
|
||||
|
||||
using namespace currency;
|
||||
|
||||
uint64_t multiassets_basic_test::ts_starter = 0;
|
||||
//------------------------------------------------------------------------------
|
||||
multiassets_basic_test::multiassets_basic_test()
|
||||
{
|
||||
// TODO: remove the following line
|
||||
static uint64_t ts = 1;
|
||||
random_state_test_restorer::reset_random(ts);
|
||||
|
||||
//LOG_PRINT_MAGENTA("STARTER TS: " << ts_starter, LOG_LEVEL_0);
|
||||
//random_state_test_restorer::reset_random(ts_starter);
|
||||
|
||||
REGISTER_CALLBACK_METHOD(multiassets_basic_test, configure_core);
|
||||
REGISTER_CALLBACK_METHOD(multiassets_basic_test, c1);
|
||||
|
|
@ -134,7 +135,7 @@ bool multiassets_basic_test::c1(currency::core& c, size_t ev_index, const std::v
|
|||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@
|
|||
|
||||
struct multiassets_basic_test : public wallet_test
|
||||
{
|
||||
static uint64_t ts_starter;
|
||||
multiassets_basic_test();
|
||||
bool generate(std::vector<test_event_entry>& events) const;
|
||||
bool c1(currency::core& c, size_t ev_index, const std::vector<test_event_entry>& events);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue