diff --git a/src/currency_core/currency_format_utils.cpp b/src/currency_core/currency_format_utils.cpp index 9c96f225..a14bcdcd 100644 --- a/src/currency_core/currency_format_utils.cpp +++ b/src/currency_core/currency_format_utils.cpp @@ -657,6 +657,14 @@ namespace currency bool r = derive_public_key_from_target_address(self.account_address, tx_sec_key, output_index, out_eph_public_key, derivation); CHECK_AND_ASSERT_MES(r, false, "failed to derive_public_key_from_target_address"); htlc.pkey_refund = out_eph_public_key; + //add derivation hint for refund address + uint16_t hint = get_derivation_hint(derivation); + if (deriv_cache.count(hint) == 0) + { + tx.extra.push_back(make_tx_derivation_hint_from_uint16(hint)); + deriv_cache.insert(hint); + } + if (htlc_dest.htlc_hash == null_hash) { @@ -2594,6 +2602,12 @@ namespace currency } tei.outs.back().minimum_sigs = otm.minimum_sigs; } + else if (out.target.type() == typeid(txout_htlc)) + { + const txout_htlc& otk = boost::get(out.target); + tei.outs.back().pub_keys.push_back(epee::string_tools::pod_to_hex(otk.pkey_redeem) + "(htlc_pkey_redeem)"); + tei.outs.back().pub_keys.push_back(epee::string_tools::pod_to_hex(otk.pkey_refund) + "(htlc_pkey_refund)"); + } ++i; } @@ -2697,7 +2711,7 @@ namespace currency { for (size_t n = 0; n < tx.vout.size(); ++n) { - if (tx.vout[n].target.type() == typeid(txout_to_key)) + if (tx.vout[n].target.type() == typeid(txout_to_key) || tx.vout[n].target.type() == typeid(txout_htlc)) { uint64_t amount = tx.vout[n].amount; gindices[amount] += 1; diff --git a/src/currency_core/tx_semantic_validation.cpp b/src/currency_core/tx_semantic_validation.cpp index 91b700b5..252c60be 100644 --- a/src/currency_core/tx_semantic_validation.cpp +++ b/src/currency_core/tx_semantic_validation.cpp @@ -30,6 +30,12 @@ namespace currency if (!ki.insert(tokey_in.k_image).second) return false; } + else if (in.type() == typeid(txin_htlc)) + { + CHECKED_GET_SPECIFIC_VARIANT(in, const txin_htlc, htlc_in, false); + if (!ki.insert(htlc_in.k_image).second) + return false; + } } return true; } diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 91115f5f..95348f24 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -461,7 +461,7 @@ void wallet2::process_new_transaction(const currency::transaction& tx, uint64_t } else if (tx.vout[o].target.type() == typeid(txout_htlc)) { - THROW_IF_TRUE_WALLET_INT_ERR_EX(htlc_info_list.size() > 0, "Found txout_htlc out but htlc_info_list is empty"); + THROW_IF_FALSE_WALLET_INT_ERR_EX(htlc_info_list.size() > 0, "Found txout_htlc out but htlc_info_list is empty"); if (htlc_info_list.front().hltc_our_out_is_before_expiration) { out_key = boost::get(tx.vout[o].target).pkey_redeem; @@ -502,7 +502,7 @@ void wallet2::process_new_transaction(const currency::transaction& tx, uint64_t else { // normal wallet, calculate and store key images for own outs - currency::keypair in_ephemeral; + currency::keypair in_ephemeral = AUTO_VAL_INIT(in_ephemeral); currency::generate_key_image_helper(m_account.get_keys(), tx_pub_key, o, in_ephemeral, ki); WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(in_ephemeral.pub == out_key, "key_image generated ephemeral public key that does not match with output_key"); } @@ -609,7 +609,14 @@ void wallet2::process_new_transaction(const currency::transaction& tx, uint64_t if (max_out_unlock_time < get_tx_unlock_time(tx, o)) max_out_unlock_time = get_tx_unlock_time(tx, o); - WLT_LOG_L0("Received money, transfer #" << transfer_index << ", amount: " << print_money(td.amount()) << ", with tx: " << get_transaction_hash(tx) << ", at height " << height); + if (tx.vout[o].target.type() == typeid(txout_to_key)) + { + WLT_LOG_L0("Received money, transfer #" << transfer_index << ", amount: " << print_money(td.amount()) << ", with tx: " << get_transaction_hash(tx) << ", at height " << height); + } + else if (tx.vout[o].target.type() == typeid(txout_htlc)) + { + WLT_LOG_L0("Detected HTLC[" << (td.m_flags&WALLET_TRANSFER_DETAIL_FLAG_HTLC_REDEEM ? "REDEEM":"REFUND") << "], transfer #" << transfer_index << ", amount: " << print_money(td.amount()) << ", with tx: " << get_transaction_hash(tx) << ", at height " << height); + } } else if (tx.vout[o].target.type() == typeid(txout_multisig)) { @@ -620,10 +627,6 @@ void wallet2::process_new_transaction(const currency::transaction& tx, uint64_t tdb.m_internal_output_index = o; WLT_LOG_L0("Received multisig, multisig out id: " << multisig_id << ", amount: " << tdb.amount() << ", with tx: " << get_transaction_hash(tx)); } - else if (tx.vout[o].target.type() == typeid(txout_htlc)) - { - - } } }