forked from lthn/blockchain
address/account refactoring in progress
This commit is contained in:
parent
8d62e84c7a
commit
f7d6782250
8 changed files with 57 additions and 49 deletions
|
|
@ -47,9 +47,9 @@ namespace currency
|
|||
//-----------------------------------------------------------------
|
||||
void account_base::generate()
|
||||
{
|
||||
generate_brain_keys(m_keys.m_account_address.m_spend_public_key, m_keys.m_spend_secret_key, m_seed, BRAINWALLET_DEFAULT_SEED_SIZE);
|
||||
generate_brain_keys(m_keys.m_account_address.spend_public_key, m_keys.m_spend_secret_key, m_seed, BRAINWALLET_DEFAULT_SEED_SIZE);
|
||||
dependent_key(m_keys.m_spend_secret_key, m_keys.m_view_secret_key);
|
||||
if (!crypto::secret_key_to_public_key(m_keys.m_view_secret_key, m_keys.m_account_address.m_view_public_key))
|
||||
if (!crypto::secret_key_to_public_key(m_keys.m_view_secret_key, m_keys.m_account_address.view_public_key))
|
||||
throw std::runtime_error("Failed to create public view key");
|
||||
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ namespace currency
|
|||
//CHECK_AND_ASSERT_MES(restore_data.size() == ACCOUNT_RESTORE_DATA_SIZE, false, "wrong restore data size");
|
||||
if (restore_data.size() == BRAINWALLET_DEFAULT_SEED_SIZE)
|
||||
{
|
||||
crypto::keys_from_default((unsigned char*)restore_data.data(), m_keys.m_account_address.m_spend_public_key, m_keys.m_spend_secret_key, BRAINWALLET_DEFAULT_SEED_SIZE);
|
||||
crypto::keys_from_default((unsigned char*)restore_data.data(), m_keys.m_account_address.spend_public_key, m_keys.m_spend_secret_key, BRAINWALLET_DEFAULT_SEED_SIZE);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -94,7 +94,7 @@ namespace currency
|
|||
}
|
||||
m_seed = restore_data;
|
||||
crypto::dependent_key(m_keys.m_spend_secret_key, m_keys.m_view_secret_key);
|
||||
bool r = crypto::secret_key_to_public_key(m_keys.m_view_secret_key, m_keys.m_account_address.m_view_public_key);
|
||||
bool r = crypto::secret_key_to_public_key(m_keys.m_view_secret_key, m_keys.m_account_address.view_public_key);
|
||||
CHECK_AND_ASSERT_MES(r, false, "failed to secret_key_to_public_key for view key");
|
||||
set_createtime(0);
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -3263,11 +3263,11 @@ bool blockchain_storage::put_alias_info(const transaction & tx, extra_alias_entr
|
|||
//std::string signed_buff;
|
||||
//make_tx_extra_alias_entry(signed_buff, ai, true);
|
||||
std::string old_address = currency::get_account_address_as_str(local_alias_history.back().m_address);
|
||||
bool r = crypto::check_signature(get_sign_buff_hash_for_alias_update(ai), local_alias_history.back().m_address.m_spend_public_key, ai.m_sign.back());
|
||||
bool r = crypto::check_signature(get_sign_buff_hash_for_alias_update(ai), local_alias_history.back().m_address.spend_public_key, ai.m_sign.back());
|
||||
CHECK_AND_ASSERT_MES(r, false, "Failed to check signature, alias update failed." << ENDL
|
||||
<< "alias: " << ai.m_alias << ENDL
|
||||
<< "signed_buff_hash: " << get_sign_buff_hash_for_alias_update(ai) << ENDL
|
||||
<< "public key: " << local_alias_history.back().m_address.m_spend_public_key << ENDL
|
||||
<< "public key: " << local_alias_history.back().m_address.spend_public_key << ENDL
|
||||
<< "new_address: " << get_account_address_as_str(ai.m_address) << ENDL
|
||||
<< "signature: " << epee::string_tools::pod_to_hex(ai.m_sign) << ENDL
|
||||
<< "alias_history.size() = " << local_alias_history.size());
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@ namespace boost
|
|||
template<class archive_t>
|
||||
void serialize(archive_t & ar, currency::extra_alias_entry_base& ai, const unsigned int version)
|
||||
{
|
||||
ar & ai.m_address.m_spend_public_key;
|
||||
ar & ai.m_address.m_view_public_key;
|
||||
ar & ai.m_address.spend_public_key;
|
||||
ar & ai.m_address.view_public_key;
|
||||
ar & ai.m_view_key;
|
||||
ar & ai.m_sign;
|
||||
ar & ai.m_text_comment;
|
||||
|
|
|
|||
|
|
@ -303,14 +303,12 @@ namespace currency
|
|||
std::string m_text_comment;
|
||||
std::vector<crypto::secret_key> m_view_key; // only one or zero elments expected (std::vector is using as memory efficient container for such a case)
|
||||
std::vector<crypto::signature> m_sign; // only one or zero elments expected (std::vector is using as memory efficient container for such a case)
|
||||
//uint8_t flags;
|
||||
|
||||
BEGIN_SERIALIZE()
|
||||
FIELD(m_address)
|
||||
FIELD(m_text_comment)
|
||||
FIELD(m_view_key)
|
||||
FIELD(m_sign)
|
||||
//FIELD(flags)
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
|
|
@ -390,10 +388,15 @@ namespace currency
|
|||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
typedef boost::mpl::vector<tx_service_attachment, tx_comment, tx_payer, tx_receiver, tx_derivation_hint, std::string, tx_crypto_checksum, etc_tx_time, etc_tx_details_unlock_time, etc_tx_details_expiration_time, etc_tx_details_flags, crypto::public_key, extra_attachment_info, extra_alias_entry, extra_user_data, extra_padding, etc_tx_uint16_t, etc_tx_details_unlock_time2> all_payload_types;
|
||||
typedef boost::make_variant_over<all_payload_types>::type attachment_v;
|
||||
typedef boost::make_variant_over<all_payload_types>::type extra_v;
|
||||
typedef boost::mpl::vector<
|
||||
tx_service_attachment, tx_comment, tx_payer, tx_receiver, tx_derivation_hint, std::string, tx_crypto_checksum, etc_tx_time, etc_tx_details_unlock_time, etc_tx_details_expiration_time,
|
||||
etc_tx_details_flags, crypto::public_key, extra_attachment_info, extra_alias_entry, extra_user_data, extra_padding, etc_tx_uint16_t, etc_tx_details_unlock_time2
|
||||
> all_payload_types;
|
||||
|
||||
typedef boost::make_variant_over<all_payload_types>::type payload_items_v;
|
||||
typedef payload_items_v extra_v;
|
||||
typedef payload_items_v attachment_v;
|
||||
|
||||
|
||||
class transaction_prefix
|
||||
{
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@ namespace boost
|
|||
{
|
||||
a & x.acc_addr;
|
||||
}
|
||||
|
||||
template <class Archive>
|
||||
inline void serialize(Archive &a, currency::tx_crypto_checksum &x, const boost::serialization::version_type ver)
|
||||
{
|
||||
|
|
@ -189,21 +190,25 @@ namespace boost
|
|||
{
|
||||
a & at.v;
|
||||
}
|
||||
|
||||
template <class Archive>
|
||||
inline void serialize(Archive &a, currency::etc_tx_details_unlock_time2 &at, const boost::serialization::version_type ver)
|
||||
{
|
||||
a & at.unlock_time_array;
|
||||
}
|
||||
|
||||
template <class Archive>
|
||||
inline void serialize(Archive &a, currency::etc_tx_details_expiration_time &at, const boost::serialization::version_type ver)
|
||||
{
|
||||
a & at.v;
|
||||
}
|
||||
|
||||
template <class Archive>
|
||||
inline void serialize(Archive &a, currency::etc_tx_details_flags &at, const boost::serialization::version_type ver)
|
||||
{
|
||||
a & at.v;
|
||||
}
|
||||
|
||||
template <class Archive>
|
||||
inline void serialize(Archive &a, currency::etc_tx_time &at, const boost::serialization::version_type ver)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -227,8 +227,8 @@ namespace currency
|
|||
bool r = crypto::generate_key_derivation(tx_public_key, ack.m_view_secret_key, recv_derivation);
|
||||
CHECK_AND_ASSERT_MES(r, false, "key image helper: failed to generate_key_derivation(" << tx_public_key << ", " << ack.m_view_secret_key << ")");
|
||||
|
||||
r = crypto::derive_public_key(recv_derivation, real_output_index, ack.m_account_address.m_spend_public_key, in_ephemeral.pub);
|
||||
CHECK_AND_ASSERT_MES(r, false, "key image helper: failed to derive_public_key(" << recv_derivation << ", " << real_output_index << ", " << ack.m_account_address.m_spend_public_key << ")");
|
||||
r = crypto::derive_public_key(recv_derivation, real_output_index, ack.m_account_address.spend_public_key, in_ephemeral.pub);
|
||||
CHECK_AND_ASSERT_MES(r, false, "key image helper: failed to derive_public_key(" << recv_derivation << ", " << real_output_index << ", " << ack.m_account_address.spend_public_key << ")");
|
||||
|
||||
crypto::derive_secret_key(recv_derivation, real_output_index, ack.m_spend_secret_key, in_ephemeral.sec);
|
||||
return true;
|
||||
|
|
@ -510,11 +510,11 @@ namespace currency
|
|||
//---------------------------------------------------------------
|
||||
bool derive_public_key_from_target_address(const account_public_address& destination_addr, const crypto::secret_key& tx_sec_key, size_t index, crypto::public_key& out_eph_public_key, crypto::key_derivation& derivation)
|
||||
{
|
||||
bool r = crypto::generate_key_derivation(destination_addr.m_view_public_key, tx_sec_key, derivation);
|
||||
CHECK_AND_ASSERT_MES(r, false, "at creation outs: failed to generate_key_derivation(" << destination_addr.m_view_public_key << ", " << tx_sec_key << ")");
|
||||
bool r = crypto::generate_key_derivation(destination_addr.view_public_key, tx_sec_key, derivation);
|
||||
CHECK_AND_ASSERT_MES(r, false, "at creation outs: failed to generate_key_derivation(" << destination_addr.view_public_key << ", " << tx_sec_key << ")");
|
||||
|
||||
r = crypto::derive_public_key(derivation, index, destination_addr.m_spend_public_key, out_eph_public_key);
|
||||
CHECK_AND_ASSERT_MES(r, false, "at creation outs: failed to derive_public_key(" << derivation << ", " << index << ", " << destination_addr.m_view_public_key << ")");
|
||||
r = crypto::derive_public_key(derivation, index, destination_addr.spend_public_key, out_eph_public_key);
|
||||
CHECK_AND_ASSERT_MES(r, false, "at creation outs: failed to derive_public_key(" << derivation << ", " << index << ", " << destination_addr.view_public_key << ")");
|
||||
return r;
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
|
|
@ -561,7 +561,7 @@ namespace currency
|
|||
for (auto& apa : de.addr)
|
||||
{
|
||||
crypto::public_key out_eph_public_key = AUTO_VAL_INIT(out_eph_public_key);
|
||||
if (apa.m_spend_public_key == null_pkey && apa.m_view_public_key == null_pkey)
|
||||
if (apa.spend_public_key == null_pkey && apa.view_public_key == null_pkey)
|
||||
{
|
||||
//burning money(for example alias reward)
|
||||
out_eph_public_key = null_pkey;
|
||||
|
|
@ -833,7 +833,7 @@ namespace currency
|
|||
void encrypt_attachments(transaction& tx, const account_keys& sender_keys, const account_public_address& destination_addr, const keypair& tx_random_key)
|
||||
{
|
||||
crypto::key_derivation derivation = AUTO_VAL_INIT(derivation);
|
||||
bool r = crypto::generate_key_derivation(destination_addr.m_view_public_key, tx_random_key.sec, derivation);
|
||||
bool r = crypto::generate_key_derivation(destination_addr.view_public_key, tx_random_key.sec, derivation);
|
||||
CHECK_AND_ASSERT_MES(r, void(), "failed to generate_key_derivation");
|
||||
bool was_attachment_crypted_entries = false;
|
||||
bool was_extra_crypted_entries = false;
|
||||
|
|
@ -1524,7 +1524,7 @@ namespace currency
|
|||
bool is_out_to_acc(const account_keys& acc, const txout_to_key& out_key, const crypto::key_derivation& derivation, size_t output_index)
|
||||
{
|
||||
crypto::public_key pk;
|
||||
if (!derive_public_key(derivation, output_index, acc.m_account_address.m_spend_public_key, pk))
|
||||
if (!derive_public_key(derivation, output_index, acc.m_account_address.spend_public_key, pk))
|
||||
return false;
|
||||
return pk == out_key.key;
|
||||
}
|
||||
|
|
@ -1532,7 +1532,7 @@ namespace currency
|
|||
bool is_out_to_acc(const account_keys& acc, const txout_multisig& out_multisig, const crypto::key_derivation& derivation, size_t output_index)
|
||||
{
|
||||
crypto::public_key pk;
|
||||
if (!derive_public_key(derivation, output_index, acc.m_account_address.m_spend_public_key, pk))
|
||||
if (!derive_public_key(derivation, output_index, acc.m_account_address.spend_public_key, pk))
|
||||
return false;
|
||||
auto it = std::find(out_multisig.keys.begin(), out_multisig.keys.end(), pk);
|
||||
if (out_multisig.keys.end() == it)
|
||||
|
|
@ -2060,8 +2060,8 @@ namespace currency
|
|||
//---------------------------------------------------------------
|
||||
bool get_aliases_reward_account(account_public_address& acc)
|
||||
{
|
||||
bool r = string_tools::parse_tpod_from_hex_string(ALIAS_REWARDS_ACCOUNT_SPEND_PUB_KEY, acc.m_spend_public_key);
|
||||
r &= string_tools::parse_tpod_from_hex_string(ALIAS_REWARDS_ACCOUNT_VIEW_PUB_KEY, acc.m_view_public_key);
|
||||
bool r = string_tools::parse_tpod_from_hex_string(ALIAS_REWARDS_ACCOUNT_SPEND_PUB_KEY, acc.spend_public_key);
|
||||
r &= string_tools::parse_tpod_from_hex_string(ALIAS_REWARDS_ACCOUNT_VIEW_PUB_KEY, acc.view_public_key);
|
||||
return r;
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
|
|
@ -2569,7 +2569,7 @@ namespace currency
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!crypto::check_key(addr.m_spend_public_key) || !crypto::check_key(addr.m_view_public_key))
|
||||
if (!crypto::check_key(addr.spend_public_key) || !crypto::check_key(addr.view_public_key))
|
||||
{
|
||||
LOG_PRINT_L1("Failed to validate address keys for address \"" << str << "\"");
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -771,7 +771,7 @@ bool wallet2::handle_proposal(wallet_public::wallet_transfer_info& wti, const bc
|
|||
wallet_public::escrow_contract_details_basic& ed = epee::misc_utils::get_or_insert_value_initialized(m_contracts, ms_id);
|
||||
ed.expiration_time = currency::get_tx_expiration_time(prop.tx_template);
|
||||
ed.timestamp = wti.timestamp;
|
||||
ed.is_a = cpd.a_addr.m_spend_public_key == m_account.get_keys().m_account_address.m_spend_public_key;
|
||||
ed.is_a = cpd.a_addr.spend_public_key == m_account.get_keys().m_account_address.spend_public_key;
|
||||
change_contract_state(ed, wallet_public::escrow_contract_details_basic::proposal_sent, ms_id, wti);
|
||||
ed.private_detailes = cpd;
|
||||
currency::get_payment_id_from_tx(decrypted_items, ed.payment_id);
|
||||
|
|
@ -1299,8 +1299,8 @@ bool wallet2::has_related_alias_entry_unconfirmed(const currency::transaction& t
|
|||
if (tei.m_alias.m_alias.size())
|
||||
{
|
||||
//have some check address involved
|
||||
if (tei.m_alias.m_address.m_spend_public_key == m_account.get_keys().m_account_address.m_spend_public_key &&
|
||||
tei.m_alias.m_address.m_view_public_key == m_account.get_keys().m_account_address.m_view_public_key)
|
||||
if (tei.m_alias.m_address.spend_public_key == m_account.get_keys().m_account_address.spend_public_key &&
|
||||
tei.m_alias.m_address.view_public_key == m_account.get_keys().m_account_address.view_public_key)
|
||||
return true;
|
||||
|
||||
//check if it's update and address before was our address
|
||||
|
|
@ -1972,11 +1972,11 @@ void wallet2::load_keys(const std::string& buff, const std::string& password)
|
|||
|
||||
const currency::account_keys& keys = m_account.get_keys();
|
||||
r = epee::serialization::load_t_from_binary(m_account, account_data);
|
||||
r = r && verify_keys(keys.m_view_secret_key, keys.m_account_address.m_view_public_key);
|
||||
r = r && verify_keys(keys.m_view_secret_key, keys.m_account_address.view_public_key);
|
||||
if (keys.m_spend_secret_key == currency::null_skey)
|
||||
m_watch_only = true;
|
||||
else
|
||||
r = r && verify_keys(keys.m_spend_secret_key, keys.m_account_address.m_spend_public_key);
|
||||
r = r && verify_keys(keys.m_spend_secret_key, keys.m_account_address.spend_public_key);
|
||||
if (!r)
|
||||
{
|
||||
WLT_LOG_L0("Wrong password for wallet " << string_encoding::convert_to_ansii(m_wallet_file));
|
||||
|
|
@ -2412,7 +2412,7 @@ void wallet2::sign_transfer(const std::string& tx_sources_blob, std::string& sig
|
|||
THROW_IF_FALSE_WALLET_EX(r, error::wallet_common_error, "Failed to decrypt tx sources blob");
|
||||
|
||||
// make sure unsigned tx was created with the same keys
|
||||
THROW_IF_FALSE_WALLET_EX(ft.ftp.spend_pub_key == m_account.get_keys().m_account_address.m_spend_public_key, error::wallet_common_error, "The was created in a different wallet, keys missmatch");
|
||||
THROW_IF_FALSE_WALLET_EX(ft.ftp.spend_pub_key == m_account.get_keys().m_account_address.spend_public_key, error::wallet_common_error, "The was created in a different wallet, keys missmatch");
|
||||
|
||||
finalize_transaction(ft.ftp, ft.tx, ft.one_time_key, false);
|
||||
|
||||
|
|
@ -2420,11 +2420,11 @@ void wallet2::sign_transfer(const std::string& tx_sources_blob, std::string& sig
|
|||
crypto::key_derivation derivation = AUTO_VAL_INIT(derivation);
|
||||
WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(
|
||||
crypto::generate_key_derivation(
|
||||
m_account.get_keys().m_account_address.m_view_public_key,
|
||||
m_account.get_keys().m_account_address.view_public_key,
|
||||
ft.one_time_key,
|
||||
derivation),
|
||||
"internal error: sign_transfer: failed to generate key derivation("
|
||||
<< m_account.get_keys().m_account_address.m_view_public_key
|
||||
<< m_account.get_keys().m_account_address.view_public_key
|
||||
<< ", view secret key: " << ft.one_time_key << ")");
|
||||
|
||||
for (size_t i = 0; i < ft.tx.vout.size(); ++i)
|
||||
|
|
@ -2435,7 +2435,7 @@ void wallet2::sign_transfer(const std::string& tx_sources_blob, std::string& sig
|
|||
const txout_to_key& otk = boost::get<txout_to_key>(out.target);
|
||||
|
||||
crypto::public_key ephemeral_pub = AUTO_VAL_INIT(ephemeral_pub);
|
||||
if (!crypto::derive_public_key(derivation, i, m_account.get_keys().m_account_address.m_spend_public_key, ephemeral_pub))
|
||||
if (!crypto::derive_public_key(derivation, i, m_account.get_keys().m_account_address.spend_public_key, ephemeral_pub))
|
||||
{
|
||||
WLT_LOG_ERROR("derive_public_key failed for tx " << get_transaction_hash(ft.tx) << ", out # " << i);
|
||||
}
|
||||
|
|
@ -2496,7 +2496,7 @@ void wallet2::submit_transfer(const std::string& signed_tx_blob, currency::trans
|
|||
crypto::hash tx_hash = get_transaction_hash(tx);
|
||||
|
||||
// foolproof
|
||||
THROW_IF_FALSE_WALLET_CMN_ERR_EX(ft.ftp.spend_pub_key == m_account.get_keys().m_account_address.m_spend_public_key, "The given tx was created in a different wallet, keys missmatch, tx hash: " << tx_hash);
|
||||
THROW_IF_FALSE_WALLET_CMN_ERR_EX(ft.ftp.spend_pub_key == m_account.get_keys().m_account_address.spend_public_key, "The given tx was created in a different wallet, keys missmatch, tx hash: " << tx_hash);
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -3062,12 +3062,12 @@ void wallet2::request_alias_update(currency::extra_alias_entry& ai, currency::tr
|
|||
{
|
||||
throw std::runtime_error(std::string("wrong alias characters: ") + ai.m_alias);
|
||||
}
|
||||
bool r = currency::sign_extra_alias_entry(ai, m_account.get_keys().m_account_address.m_spend_public_key, m_account.get_keys().m_spend_secret_key);
|
||||
bool r = currency::sign_extra_alias_entry(ai, m_account.get_keys().m_account_address.spend_public_key, m_account.get_keys().m_spend_secret_key);
|
||||
CHECK_AND_ASSERT_THROW_MES(r, "Failed to sign alias update");
|
||||
WLT_LOG_L2("Generated upodate alias info: " << ENDL
|
||||
<< "alias: " << ai.m_alias << ENDL
|
||||
<< "signature: " << currency::print_t_array(ai.m_sign) << ENDL
|
||||
<< "signed(owner) pub key: " << m_account.get_keys().m_account_address.m_spend_public_key << ENDL
|
||||
<< "signed(owner) pub key: " << m_account.get_keys().m_account_address.spend_public_key << ENDL
|
||||
<< "transfered to address: " << get_account_address_as_str(ai.m_address) << ENDL
|
||||
<< "signed_hash: " << currency::get_sign_buff_hash_for_alias_update(ai)
|
||||
);
|
||||
|
|
@ -3953,8 +3953,8 @@ bool wallet2::read_money_transfer2_details_from_tx(const transaction& tx, const
|
|||
PROFILE_FUNC("wallet2::read_money_transfer2_details_from_tx");
|
||||
for (auto& d : splitted_dsts)
|
||||
{
|
||||
if (d.addr.size() && d.addr.back().m_spend_public_key == m_account.get_keys().m_account_address.m_spend_public_key &&
|
||||
d.addr.back().m_view_public_key == m_account.get_keys().m_account_address.m_view_public_key)
|
||||
if (d.addr.size() && d.addr.back().spend_public_key == m_account.get_keys().m_account_address.spend_public_key &&
|
||||
d.addr.back().view_public_key == m_account.get_keys().m_account_address.view_public_key)
|
||||
wtd.rcv.push_back(d.amount);
|
||||
}
|
||||
|
||||
|
|
@ -4191,7 +4191,7 @@ void wallet2::prepare_transaction(const construct_tx_param& ctp, finalize_tx_par
|
|||
ftp.shuffle = ctp.shuffle;
|
||||
ftp.flags = ctp.flags;
|
||||
ftp.multisig_id = ctp.multisig_id;
|
||||
ftp.spend_pub_key = m_account.get_public_address().m_spend_public_key;
|
||||
ftp.spend_pub_key = m_account.get_public_address().spend_public_key;
|
||||
|
||||
/* TODO
|
||||
WLT_LOG_GREEN("[prepare_transaction]: get_needed_money_time: " << get_needed_money_time << " ms"
|
||||
|
|
@ -4510,7 +4510,7 @@ void wallet2::sweep_below(size_t fake_outs_count, const currency::account_public
|
|||
// ftp.selected_transfers -- needed only at stage of broadcasting or storing unsigned tx
|
||||
ftp.shuffle = false;
|
||||
// ftp.sources -- will be filled in try_construct_tx
|
||||
ftp.spend_pub_key = m_account.get_public_address().m_spend_public_key; // needed for offline signing
|
||||
ftp.spend_pub_key = m_account.get_public_address().spend_public_key; // needed for offline signing
|
||||
ftp.tx_outs_attr = CURRENCY_TO_KEY_OUT_RELAXED;
|
||||
ftp.unlock_time = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -93,13 +93,13 @@ bool wallet2::validate_escrow_proposal(const wallet_public::wallet_transfer_info
|
|||
|
||||
crypto::public_key a_key = AUTO_VAL_INIT(a_key), b_key = AUTO_VAL_INIT(b_key);
|
||||
crypto::key_derivation der = AUTO_VAL_INIT(der);
|
||||
r = crypto::generate_key_derivation(cpd.a_addr.m_view_public_key, prop.tx_onetime_secret_key, der);
|
||||
r = crypto::generate_key_derivation(cpd.a_addr.view_public_key, prop.tx_onetime_secret_key, der);
|
||||
LOC_CHK(r, "generate_key_derivation failed: A");
|
||||
r = crypto::derive_public_key(der, ms_out_index, cpd.a_addr.m_spend_public_key, a_key);
|
||||
r = crypto::derive_public_key(der, ms_out_index, cpd.a_addr.spend_public_key, a_key);
|
||||
LOC_CHK(r, "derive_public_key failed: A");
|
||||
r = crypto::generate_key_derivation(cpd.b_addr.m_view_public_key, prop.tx_onetime_secret_key, der);
|
||||
r = crypto::generate_key_derivation(cpd.b_addr.view_public_key, prop.tx_onetime_secret_key, der);
|
||||
LOC_CHK(r, "generate_key_derivation failed: B");
|
||||
r = crypto::derive_public_key(der, ms_out_index, cpd.b_addr.m_spend_public_key, b_key);
|
||||
r = crypto::derive_public_key(der, ms_out_index, cpd.b_addr.spend_public_key, b_key);
|
||||
LOC_CHK(r, "derive_public_key failed: B");
|
||||
bool correct_keys = (ms.keys[0] == a_key && ms.keys[1] == b_key) || (ms.keys[0] == b_key && ms.keys[1] == a_key);
|
||||
LOC_CHK(correct_keys, "template has mulisig output with invalid keys: 0:" << ms.keys[0] << " 1:" << ms.keys[1]);
|
||||
|
|
@ -186,7 +186,7 @@ bool wallet2::validate_escrow_release(const transaction& tx, bool release_type_n
|
|||
total_outputs_amount += tx.vout[i].amount;
|
||||
const txout_to_key& otk = boost::get<txout_to_key>(tx.vout[i].target);
|
||||
crypto::public_key ephemeral_pub_key = AUTO_VAL_INIT(ephemeral_pub_key);
|
||||
r = crypto::derive_public_key(der, i, cpd.a_addr.m_spend_public_key, ephemeral_pub_key);
|
||||
r = crypto::derive_public_key(der, i, cpd.a_addr.spend_public_key, ephemeral_pub_key);
|
||||
LOC_CHK(r, "derive_public_key failed for output #" << i);
|
||||
if (otk.key == ephemeral_pub_key)
|
||||
outputs_to_A_amount += tx.vout[i].amount;
|
||||
|
|
@ -226,7 +226,7 @@ bool wallet2::validate_escrow_release(const transaction& tx, bool release_type_n
|
|||
r = crypto::generate_key_derivation(source_tx_pub_key, a_keys.m_view_secret_key, der);
|
||||
LOC_CHK(r, "generate_key_derivation failed");
|
||||
crypto::public_key ephemeral_pub_key = AUTO_VAL_INIT(ephemeral_pub_key);
|
||||
r = crypto::derive_public_key(der, source_ms_out_index, a_keys.m_account_address.m_spend_public_key, ephemeral_pub_key);
|
||||
r = crypto::derive_public_key(der, source_ms_out_index, a_keys.m_account_address.spend_public_key, ephemeral_pub_key);
|
||||
LOC_CHK(r, "derive_public_key failed");
|
||||
|
||||
LOC_CHK(source_ms_out.keys.size() == 2, "internal error: invalid ms output keys array, size: " << source_ms_out.keys.size());
|
||||
|
|
@ -368,7 +368,7 @@ bool wallet2::validate_escrow_cancel_release(const currency::transaction& tx, co
|
|||
total_outputs_amount += tx.vout[i].amount;
|
||||
const txout_to_key& otk = boost::get<txout_to_key>(tx.vout[i].target);
|
||||
crypto::public_key ephemeral_pub_key = AUTO_VAL_INIT(ephemeral_pub_key);
|
||||
r = crypto::derive_public_key(der, i, cpd.b_addr.m_spend_public_key, ephemeral_pub_key);
|
||||
r = crypto::derive_public_key(der, i, cpd.b_addr.spend_public_key, ephemeral_pub_key);
|
||||
LOC_CHK(r, "derive_public_key failed for output #" << i);
|
||||
if (otk.key == ephemeral_pub_key)
|
||||
outputs_to_B_amount += tx.vout[i].amount;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue