Merge branch 'zarcanum_wallet' into zarcanum
This commit is contained in:
commit
018ec1eccf
3 changed files with 22 additions and 13 deletions
|
|
@ -1961,7 +1961,7 @@ namespace currency
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------
|
//---------------------------------------------------------------
|
||||||
bool lookup_acc_outs(const account_keys& acc, const transaction& tx, std::vector<size_t>& outs, uint64_t& money_transfered, crypto::key_derivation& derivation)
|
bool lookup_acc_outs(const account_keys& acc, const transaction& tx, std::vector<wallet_out_info>& outs, uint64_t& money_transfered, crypto::key_derivation& derivation)
|
||||||
{
|
{
|
||||||
crypto::public_key tx_pub_key = get_tx_pub_key_from_extra(tx);
|
crypto::public_key tx_pub_key = get_tx_pub_key_from_extra(tx);
|
||||||
if (null_pkey == tx_pub_key)
|
if (null_pkey == tx_pub_key)
|
||||||
|
|
@ -1994,7 +1994,7 @@ namespace currency
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------
|
//---------------------------------------------------------------
|
||||||
bool lookup_acc_outs_genesis(const account_keys& acc, const transaction& tx, const crypto::public_key& tx_pub_key, std::vector<size_t>& outs, uint64_t& money_transfered, crypto::key_derivation& derivation)
|
bool lookup_acc_outs_genesis(const account_keys& acc, const transaction& tx, const crypto::public_key& tx_pub_key, std::vector<wallet_out_info>& outs, uint64_t& money_transfered, crypto::key_derivation& derivation)
|
||||||
{
|
{
|
||||||
uint64_t offset = 0;
|
uint64_t offset = 0;
|
||||||
bool r = get_account_genesis_offset_by_address(get_account_address_as_str(acc.account_address), offset);
|
bool r = get_account_genesis_offset_by_address(get_account_address_as_str(acc.account_address), offset);
|
||||||
|
|
@ -2015,13 +2015,13 @@ namespace currency
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------
|
//---------------------------------------------------------------
|
||||||
bool lookup_acc_outs(const account_keys& acc, const transaction& tx, const crypto::public_key& tx_pub_key, std::vector<size_t>& outs, uint64_t& money_transfered, crypto::key_derivation& derivation)
|
bool lookup_acc_outs(const account_keys& acc, const transaction& tx, const crypto::public_key& tx_pub_key, std::vector<wallet_out_info>& outs, uint64_t& money_transfered, crypto::key_derivation& derivation)
|
||||||
{
|
{
|
||||||
std::list<htlc_info> htlc_info_list;
|
std::list<htlc_info> htlc_info_list;
|
||||||
return lookup_acc_outs(acc, tx, tx_pub_key, outs, money_transfered, derivation, htlc_info_list);
|
return lookup_acc_outs(acc, tx, tx_pub_key, outs, money_transfered, derivation, htlc_info_list);
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------
|
//---------------------------------------------------------------
|
||||||
bool lookup_acc_outs(const account_keys& acc, const transaction& tx, const crypto::public_key& tx_pub_key, std::vector<size_t>& outs, uint64_t& money_transfered, crypto::key_derivation& derivation, std::list<htlc_info>& htlc_info_list)
|
bool lookup_acc_outs(const account_keys& acc, const transaction& tx, const crypto::public_key& tx_pub_key, std::vector<wallet_out_info>& outs, uint64_t& money_transfered, crypto::key_derivation& derivation, std::list<htlc_info>& htlc_info_list)
|
||||||
{
|
{
|
||||||
money_transfered = 0;
|
money_transfered = 0;
|
||||||
bool r = generate_key_derivation(tx_pub_key, acc.view_secret_key, derivation);
|
bool r = generate_key_derivation(tx_pub_key, acc.view_secret_key, derivation);
|
||||||
|
|
|
||||||
|
|
@ -195,6 +195,12 @@ namespace currency
|
||||||
END_SERIALIZE()
|
END_SERIALIZE()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct wallet_out_info
|
||||||
|
{
|
||||||
|
size_t index;
|
||||||
|
uint64_t amount;
|
||||||
|
//todo: additional input info
|
||||||
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------
|
//---------------------------------------------------------------
|
||||||
bool construct_miner_tx(size_t height, size_t median_size, const boost::multiprecision::uint128_t& already_generated_coins,
|
bool construct_miner_tx(size_t height, size_t median_size, const boost::multiprecision::uint128_t& already_generated_coins,
|
||||||
|
|
@ -283,9 +289,9 @@ namespace currency
|
||||||
crypto::hash get_multisig_out_id(const transaction& tx, size_t n);
|
crypto::hash get_multisig_out_id(const transaction& tx, size_t n);
|
||||||
bool is_out_to_acc(const account_keys& acc, const txout_to_key& out_key, const crypto::key_derivation& derivation, size_t output_index);
|
bool is_out_to_acc(const account_keys& acc, const txout_to_key& out_key, const crypto::key_derivation& derivation, size_t output_index);
|
||||||
bool is_out_to_acc(const account_keys& acc, const txout_multisig& out_multisig, const crypto::key_derivation& derivation, size_t output_index);
|
bool is_out_to_acc(const account_keys& acc, const txout_multisig& out_multisig, const crypto::key_derivation& derivation, size_t output_index);
|
||||||
bool lookup_acc_outs(const account_keys& acc, const transaction& tx, const crypto::public_key& tx_pub_key, std::vector<size_t>& outs, uint64_t& money_transfered, crypto::key_derivation& derivation);
|
bool lookup_acc_outs(const account_keys& acc, const transaction& tx, const crypto::public_key& tx_pub_key, std::vector<wallet_out_info>& outs, uint64_t& money_transfered, crypto::key_derivation& derivation);
|
||||||
bool lookup_acc_outs(const account_keys& acc, const transaction& tx, const crypto::public_key& tx_pub_key, std::vector<size_t>& outs, uint64_t& money_transfered, crypto::key_derivation& derivation, std::list<htlc_info>& htlc_info_list);
|
bool lookup_acc_outs(const account_keys& acc, const transaction& tx, const crypto::public_key& tx_pub_key, std::vector<wallet_out_info>& outs, uint64_t& money_transfered, crypto::key_derivation& derivation, std::list<htlc_info>& htlc_info_list);
|
||||||
bool lookup_acc_outs(const account_keys& acc, const transaction& tx, std::vector<size_t>& outs, uint64_t& money_transfered, crypto::key_derivation& derivation);
|
bool lookup_acc_outs(const account_keys& acc, const transaction& tx, std::vector<wallet_out_info>& outs, uint64_t& money_transfered, crypto::key_derivation& derivation);
|
||||||
bool get_tx_fee(const transaction& tx, uint64_t & fee);
|
bool get_tx_fee(const transaction& tx, uint64_t & fee);
|
||||||
uint64_t get_tx_fee(const transaction& tx);
|
uint64_t get_tx_fee(const transaction& tx);
|
||||||
bool derive_ephemeral_key_helper(const account_keys& ack, const crypto::public_key& tx_public_key, size_t real_output_index, keypair& in_ephemeral);
|
bool derive_ephemeral_key_helper(const account_keys& ack, const crypto::public_key& tx_public_key, size_t real_output_index, keypair& in_ephemeral);
|
||||||
|
|
|
||||||
|
|
@ -328,7 +328,8 @@ void wallet2::process_new_transaction(const currency::transaction& tx, uint64_t
|
||||||
{
|
{
|
||||||
std::vector<std::string> recipients, remote_aliases;
|
std::vector<std::string> recipients, remote_aliases;
|
||||||
process_unconfirmed(tx, recipients, remote_aliases);
|
process_unconfirmed(tx, recipients, remote_aliases);
|
||||||
std::vector<size_t> outs;
|
|
||||||
|
std::vector<wallet_out_info> outs;
|
||||||
uint64_t tx_money_got_in_outs = 0;
|
uint64_t tx_money_got_in_outs = 0;
|
||||||
crypto::public_key tx_pub_key = null_pkey;
|
crypto::public_key tx_pub_key = null_pkey;
|
||||||
bool r = parse_and_validate_tx_extra(tx, tx_pub_key);
|
bool r = parse_and_validate_tx_extra(tx, tx_pub_key);
|
||||||
|
|
@ -476,7 +477,7 @@ void wallet2::process_new_transaction(const currency::transaction& tx, uint64_t
|
||||||
|
|
||||||
for (size_t i_in_outs = 0; i_in_outs != outs.size(); i_in_outs++)
|
for (size_t i_in_outs = 0; i_in_outs != outs.size(); i_in_outs++)
|
||||||
{
|
{
|
||||||
size_t o = outs[i_in_outs];
|
size_t o = outs[i_in_outs].index;
|
||||||
WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(o < tx.vout.size(), "wrong out in transaction: internal index=" << o << ", total_outs=" << tx.vout.size());
|
WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(o < tx.vout.size(), "wrong out in transaction: internal index=" << o << ", total_outs=" << tx.vout.size());
|
||||||
VARIANT_SWITCH_BEGIN(tx.vout[o]);
|
VARIANT_SWITCH_BEGIN(tx.vout[o]);
|
||||||
VARIANT_CASE_CONST(tx_out_bare, out)
|
VARIANT_CASE_CONST(tx_out_bare, out)
|
||||||
|
|
@ -1086,7 +1087,7 @@ bool wallet2::handle_proposal(wallet_public::wallet_transfer_info& wti, const bc
|
||||||
scan_tx_to_key_inputs(found_transfers, prop.tx_template);
|
scan_tx_to_key_inputs(found_transfers, prop.tx_template);
|
||||||
//scan outputs to figure out amount of change in escrow
|
//scan outputs to figure out amount of change in escrow
|
||||||
crypto::key_derivation derivation = AUTO_VAL_INIT(derivation);
|
crypto::key_derivation derivation = AUTO_VAL_INIT(derivation);
|
||||||
std::vector<size_t> outs;
|
std::vector<wallet_out_info> outs;
|
||||||
uint64_t tx_money_got_in_outs = 0;
|
uint64_t tx_money_got_in_outs = 0;
|
||||||
bool r = lookup_acc_outs(m_account.get_keys(), prop.tx_template, outs, tx_money_got_in_outs, derivation);
|
bool r = lookup_acc_outs(m_account.get_keys(), prop.tx_template, outs, tx_money_got_in_outs, derivation);
|
||||||
THROW_IF_FALSE_WALLET_INT_ERR_EX(r, "Failed to lookup_acc_outs for tx: " << get_transaction_hash(prop.tx_template));
|
THROW_IF_FALSE_WALLET_INT_ERR_EX(r, "Failed to lookup_acc_outs for tx: " << get_transaction_hash(prop.tx_template));
|
||||||
|
|
@ -1931,7 +1932,7 @@ void wallet2::scan_tx_pool(bool& has_related_alias_in_unconfirmed)
|
||||||
}
|
}
|
||||||
|
|
||||||
// read extra
|
// read extra
|
||||||
std::vector<size_t> outs;
|
std::vector<wallet_out_info> outs;
|
||||||
uint64_t tx_money_got_in_outs = 0;
|
uint64_t tx_money_got_in_outs = 0;
|
||||||
crypto::public_key tx_pub_key = null_pkey;
|
crypto::public_key tx_pub_key = null_pkey;
|
||||||
r = parse_and_validate_tx_extra(tx, tx_pub_key);
|
r = parse_and_validate_tx_extra(tx, tx_pub_key);
|
||||||
|
|
@ -1942,7 +1943,9 @@ void wallet2::scan_tx_pool(bool& has_related_alias_in_unconfirmed)
|
||||||
THROW_IF_TRUE_WALLET_EX(!r, error::acc_outs_lookup_error, tx, tx_pub_key, m_account.get_keys());
|
THROW_IF_TRUE_WALLET_EX(!r, error::acc_outs_lookup_error, tx, tx_pub_key, m_account.get_keys());
|
||||||
|
|
||||||
//collect incomes
|
//collect incomes
|
||||||
td.receive_indices = outs;
|
for (auto& o : outs)
|
||||||
|
td.receive_indices.push_back(o.index);
|
||||||
|
|
||||||
bool new_multisig_spend_detected = false;
|
bool new_multisig_spend_detected = false;
|
||||||
//check if we have spendings
|
//check if we have spendings
|
||||||
uint64_t tx_money_spent_in_ins = 0;
|
uint64_t tx_money_spent_in_ins = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue