1
0
Fork 0
forked from lthn/blockchain

Added intermediate information secure transfer between proposal and acceptance

This commit is contained in:
cryptozoidberg 2023-04-13 20:07:43 +02:00
parent c8aed60e05
commit e30341163b
No known key found for this signature in database
GPG key ID: 22DEB97A54C6FDEC
7 changed files with 146 additions and 85 deletions

View file

@ -1612,9 +1612,8 @@ namespace currency
}
//---------------------------------------------------------------
void encrypt_attachments(transaction& tx, const account_keys& sender_keys, const account_public_address& destination_addr, const keypair& tx_random_key)
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)
{
crypto::key_derivation derivation = AUTO_VAL_INIT(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;
@ -1645,6 +1644,12 @@ 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);
return encrypt_attachments(tx, sender_keys, destination_addr, tx_random_key, derivation);
}
//---------------------------------------------------------------
void load_wallet_transfer_info_flags(tools::wallet_public::wallet_transfer_info& x)
{
x.is_service = currency::is_service_tx(x.tx);
@ -2052,7 +2057,7 @@ namespace currency
//include offers if need
tx.attachment = attachments;
encrypt_attachments(tx, sender_account_keys, crypt_destination_addr, txkey);
encrypt_attachments(tx, sender_account_keys, crypt_destination_addr, txkey, result.derivation);
}
else
{
@ -2061,7 +2066,8 @@ namespace currency
CHECK_AND_ASSERT_MES(txkey.pub != null_pkey && txkey.sec != null_skey, false, "In append mode both public and secret keys must be provided");
//separately encrypt attachments without putting extra
crypto::key_derivation derivation = get_encryption_key_derivation(true, tx, sender_account_keys);
result.derivation = get_encryption_key_derivation(true, tx, sender_account_keys);
crypto::key_derivation& derivation = result.derivation;
CHECK_AND_ASSERT_MES(derivation != null_derivation, false, "failed to generate_key_derivation");
bool was_attachment_crypted_entries = false;
std::vector<extra_v> extra_local = extra;

View file

@ -183,6 +183,7 @@ namespace currency
finalize_tx_param ftp;
std::string htlc_origin;
std::vector<serializable_pair<uint64_t, crypto::key_image>> outs_key_images; // pairs (out_index, key_image) for each change output
crypto::key_derivation derivation;
BEGIN_SERIALIZE_OBJECT()
FIELD(tx)
@ -190,6 +191,7 @@ namespace currency
FIELD(ftp)
FIELD(htlc_origin)
FIELD(outs_key_images)
FIELD(derivation)
END_SERIALIZE()
};
@ -338,6 +340,7 @@ namespace currency
bool is_tx_spendtime_unlocked(uint64_t unlock_time, uint64_t current_blockchain_size, uint64_t current_time);
crypto::key_derivation get_encryption_key_derivation(bool is_income, const transaction& tx, const account_keys& acc_keys);
bool decrypt_payload_items(bool is_income, const transaction& tx, const account_keys& acc_keys, std::vector<payload_items_v>& decrypted_items);
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);
void encrypt_attachments(transaction& tx, const account_keys& sender_keys, const account_public_address& destination_addr, const keypair& tx_random_key);
bool is_derivation_used_to_encrypt(const transaction& tx, const crypto::key_derivation& derivation);
bool is_address_like_wrapped(const std::string& addr);

View file

@ -264,44 +264,46 @@ namespace currency
// consider redesign, some data may possibly be excluded from kv serialization -- sowle
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(asset_ids);
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(blinded_asset_ids);
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(amount_commitments);
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(asset_id_blinding_masks);
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(amounts);
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(amount_blinding_masks);
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(pseudo_outs_blinded_asset_ids);
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(pseudo_outs_plus_real_out_blinding_masks);
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(real_zc_ins_asset_ids);
KV_SERIALIZE_POD_AS_HEX_STRING(pseudo_out_amount_commitments_sum);
KV_SERIALIZE_POD_AS_HEX_STRING(pseudo_out_amount_blinding_masks_sum);
KV_SERIALIZE_POD_AS_HEX_STRING(real_in_asset_id_blinding_mask_x_amount_sum);
KV_SERIALIZE_POD_AS_HEX_STRING(amount_commitments_sum);
KV_SERIALIZE_POD_AS_HEX_STRING(amount_blinding_masks_sum);
KV_SERIALIZE_POD_AS_HEX_STRING(asset_id_blinding_mask_x_amount_sum);
KV_SERIALIZE_POD_AS_HEX_STRING(ao_asset_id);
KV_SERIALIZE_POD_AS_HEX_STRING(ao_asset_id_pt);
KV_SERIALIZE_POD_AS_HEX_STRING(ao_amount_commitment);
KV_SERIALIZE_POD_AS_HEX_STRING(ao_amount_blinding_mask);
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(asset_ids)
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(blinded_asset_ids)
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(amount_commitments)
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(asset_id_blinding_masks)
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(amounts)
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(amount_blinding_masks)
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(pseudo_outs_blinded_asset_ids)
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(pseudo_outs_plus_real_out_blinding_masks)
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(real_zc_ins_asset_ids)
KV_SERIALIZE_POD_AS_HEX_STRING(pseudo_out_amount_commitments_sum)
KV_SERIALIZE_POD_AS_HEX_STRING(pseudo_out_amount_blinding_masks_sum)
KV_SERIALIZE_POD_AS_HEX_STRING(real_in_asset_id_blinding_mask_x_amount_sum)
KV_SERIALIZE_POD_AS_HEX_STRING(amount_commitments_sum)
KV_SERIALIZE_POD_AS_HEX_STRING(amount_blinding_masks_sum)
KV_SERIALIZE_POD_AS_HEX_STRING(asset_id_blinding_mask_x_amount_sum)
KV_SERIALIZE_POD_AS_HEX_STRING(ao_asset_id)
KV_SERIALIZE_POD_AS_HEX_STRING(ao_asset_id_pt)
KV_SERIALIZE_POD_AS_HEX_STRING(ao_amount_commitment)
KV_SERIALIZE_POD_AS_HEX_STRING(ao_amount_blinding_mask)
END_KV_SERIALIZE_MAP()
// solely for consolidated txs, asset opration fields are not serialized
BEGIN_SERIALIZE_OBJECT()
FIELD(asset_ids);
FIELD(blinded_asset_ids);
FIELD(amount_commitments);
FIELD((std::vector<crypto::scalar_t>&)(asset_id_blinding_masks));
FIELD((std::vector<crypto::scalar_t>&)(amounts));
FIELD((std::vector<crypto::scalar_t>&)(amount_blinding_masks));
FIELD(pseudo_outs_blinded_asset_ids);
FIELD((std::vector<crypto::scalar_t>&)(pseudo_outs_plus_real_out_blinding_masks));
FIELD(real_zc_ins_asset_ids);
FIELD(pseudo_out_amount_commitments_sum);
FIELD(pseudo_out_amount_blinding_masks_sum);
FIELD(real_in_asset_id_blinding_mask_x_amount_sum);
FIELD(amount_commitments_sum);
FIELD(amount_blinding_masks_sum);
FIELD(asset_id_blinding_mask_x_amount_sum);
VERSION()
CURRENT_VERSION(0)
FIELD(asset_ids)
FIELD(blinded_asset_ids)
FIELD(amount_commitments)
FIELD((std::vector<crypto::scalar_t>&)(asset_id_blinding_masks))
FIELD((std::vector<crypto::scalar_t>&)(amounts))
FIELD((std::vector<crypto::scalar_t>&)(amount_blinding_masks))
FIELD(pseudo_outs_blinded_asset_ids)
FIELD((std::vector<crypto::scalar_t>&)(pseudo_outs_plus_real_out_blinding_masks))
FIELD(real_zc_ins_asset_ids)
FIELD(pseudo_out_amount_commitments_sum)
FIELD(pseudo_out_amount_blinding_masks_sum)
FIELD(real_in_asset_id_blinding_mask_x_amount_sum)
FIELD(amount_commitments_sum)
FIELD(amount_blinding_masks_sum)
FIELD(asset_id_blinding_mask_x_amount_sum)
// no asset operation fields here
//ao_asset_id

View file

@ -4967,12 +4967,11 @@ bool wallet2::check_htlc_redeemed(const crypto::hash& htlc_tx_id, std::string& o
return false;
}
//----------------------------------------------------------------------------------------------------
bool wallet2::create_ionic_swap_proposal(const wallet_public::ionic_swap_proposal_info& proposal_details, const currency::account_public_address& destination_addr, currency::transaction& tx_template)
bool wallet2::create_ionic_swap_proposal(const wallet_public::ionic_swap_proposal_info& proposal_details, const currency::account_public_address& destination_addr, ionic_swap_proposal& proposal)
{
crypto::secret_key one_time_key = AUTO_VAL_INIT(one_time_key);
std::vector<uint64_t> selected_transfers_for_template;
build_ionic_swap_template(proposal_details, destination_addr, tx_template, selected_transfers_for_template, one_time_key);
build_ionic_swap_template(proposal_details, destination_addr, proposal, selected_transfers_for_template);
const uint32_t mask_to_mark_escrow_template_locked_transfers = WALLET_TRANSFER_DETAIL_FLAG_BLOCKED | WALLET_TRANSFER_DETAIL_FLAG_ESCROW_PROPOSAL_RESERVATION;
mark_transfers_with_flag(selected_transfers_for_template, mask_to_mark_escrow_template_locked_transfers, "preparing ionic_swap");
@ -4980,10 +4979,10 @@ bool wallet2::create_ionic_swap_proposal(const wallet_public::ionic_swap_proposa
}
//----------------------------------------------------------------------------------------------------
bool wallet2::build_ionic_swap_template(const wallet_public::ionic_swap_proposal_info& proposal_detais, const currency::account_public_address& destination_addr,
currency::transaction& template_tx,
std::vector<uint64_t>& selected_transfers,
crypto::secret_key& one_time_key)
ionic_swap_proposal& proposal,
std::vector<uint64_t>& selected_transfers)
{
ionic_swap_proposal& proposal.tx_template;
construct_tx_param ctp = get_default_construct_tx_param();
ctp.fake_outputs_count = proposal_detais.mixins;
@ -5019,29 +5018,54 @@ bool wallet2::build_ionic_swap_template(const wallet_public::ionic_swap_proposal
prepare_transaction(ctp, ftp);
selected_transfers = ftp.selected_transfers;
currency::finalized_tx finalize_result = AUTO_VAL_INIT(finalize_result);
finalize_transaction(ftp, finalize_result, false);
add_transfers_to_expiration_list(selected_transfers, finalize_result, 0, currency::null_hash);
finalize_transaction(ftp, template_tx, one_time_key, false);
add_transfers_to_expiration_list(selected_transfers, t.v, 0, currency::null_hash);
//wrap it all
proposal.tx_template = finalize_result.tx;
ionic_swap_proposal_context ispc = AUTO_VAL_INIT(ispc);
ispc.gen_context = finalize_result.ftp.gen_context;
ispc.one_time_skey = finalize_result.one_time_key;
std::string proposal_context_blob = t_serializable_object_to_blob(ispc);
proposal.encrypted_context = crypto::chacha_crypt(proposal_context_blob, finalize_result.derivation);
return true;
}
//----------------------------------------------------------------------------------------------------
bool wallet2::get_ionic_swap_proposal_info(const std::string&raw_tx_template, wallet_public::ionic_swap_proposal_info& proposal)
bool wallet2::get_ionic_swap_proposal_info(const std::string&raw_proposal, wallet_public::ionic_swap_proposal_info& proposal_info)
{
currency::transaction tx;
bool r = parse_and_validate_tx_from_blob(raw_tx_template, tx);
THROW_IF_TRUE_WALLET_EX(!r, error::tx_parse_error, raw_tx_template);
return get_ionic_swap_proposal_info(tx, proposal);
wallet_public::ionic_swap_proposal proposal = AUTO_VAL_INIT(proposal);
bool r = t_unserializable_object_from_blob(raw_proposal, proposal);
THROW_IF_TRUE_WALLET_EX(!r, error::wallet_internal_error, "Failed to parse proposal");
return get_ionic_swap_proposal_info(proposal, proposal_info);
}
//----------------------------------------------------------------------------------------------------
bool wallet2::get_ionic_swap_proposal_info(const currency::transaction tx, wallet_public::ionic_swap_proposal_info& proposal)
bool wallet2::get_ionic_swap_proposal_info(const wallet_public::ionic_swap_proposal& proposal, wallet_public::ionic_swap_proposal_info& proposal_info)
{
wallet_public::ionic_swap_proposal_context ionic_context = AUTO_VAL_INIT(ionic_context);
return get_ionic_swap_proposal_info(proposal, proposal_info, ionic_context);
}
//----------------------------------------------------------------------------------------------------
bool wallet2::get_ionic_swap_proposal_info(const wallet_public::ionic_swap_proposal& proposal, wallet_public::ionic_swap_proposal_info& proposal_info, wallet_public::ionic_swap_proposal_context& ionic_context)
{
const transaction& tx = proposal.tx_template;
crypto::key_derivation derivation = AUTO_VAL_INIT(derivation);
std::vector<wallet_out_info> outs;
uint64_t tx_money_got_in_outs = 0;
bool r = lookup_acc_outs(m_account.get_keys(), tx, 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(tx));
if (!outs.size())
{
return false;
}
//decrypt context
std::string decrypted_raw_context = crypto::chacha_crypt(proposal.encrypted_context, derivation);
r = t_unserializable_object_from_blob(ionic_context, decrypted_raw_context);
THROW_IF_FALSE_WALLET_INT_ERR_EX(r, "Failed to unserialize decrypted ionic_context");
std::unordered_map<crypto::public_key, uint64_t> ammounts_to;
std::unordered_map<crypto::public_key, uint64_t> ammounts_from;
std::vector<bool> third_party_outs;
@ -5066,50 +5090,50 @@ bool wallet2::get_ionic_swap_proposal_info(const currency::transaction tx, walle
}
for (const auto& a : ammounts_to)
proposal.to.push_back(view::asset_funds{ a.first, a.second });
proposal_info.to.push_back(view::asset_funds{ a.first, a.second });
for (const auto& a : ammounts_from)
proposal.from.push_back(view::asset_funds{ a.first, a.second });
proposal_info.from.push_back(view::asset_funds{ a.first, a.second });
for (const auto&in : tx.vin)
{
if (in.type() != typeid(currency::txin_zc_input))
return false;
size_t mx = boost::get<currency::txin_zc_input>(in).key_offsets.size() - 1;
if (proposal.mixins == 0 || proposal.mixins > mx)
if (proposal_info.mixins == 0 || proposal_info.mixins > mx)
{
proposal.mixins = mx;
proposal_info.mixins = mx;
}
}
proposal.fee = currency::get_tx_fee(tx);
proposal_info.fee = currency::get_tx_fee(tx);
etc_tx_details_expiration_time t = AUTO_VAL_INIT(t);
if (!get_type_in_variant_container(tx.extra, t))
{
return false;
}
proposal.expiration_time = t.v;
proposal_info.expiration_time = t.v;
return true;
}
//----------------------------------------------------------------------------------------------------
bool wallet2::accept_ionic_swap_proposal(const std::string& raw_tx_template, currency::transaction& result_tx)
bool wallet2::accept_ionic_swap_proposal(const std::string& raw_proposal, currency::transaction& result_tx)
{
currency::transaction tx;
bool r = parse_and_validate_tx_from_blob(raw_tx_template, tx);
THROW_IF_TRUE_WALLET_EX(!r, error::tx_parse_error, raw_tx_template);
const wallet_public::ionic_swap_proposal proposal = AUTO_VAL_INIT(proposal);
bool r = parse_and_validate_tx_from_blob(raw_proposal, proposal);
THROW_IF_TRUE_WALLET_EX(!r, error::wallet_internal_error, "Failed to parse proposal info");
return accept_ionic_swap_proposal(tx, result_tx);
return accept_ionic_swap_proposal(proposal, result_tx);
}
//----------------------------------------------------------------------------------------------------
bool wallet2::accept_ionic_swap_proposal(const currency::transaction& tx_template, currency::transaction& result_tx)
bool wallet2::accept_ionic_swap_proposal(const wallet_public::ionic_swap_proposal& proposal, currency::transaction& result_tx)
{
mode_separate_context msc = AUTO_VAL_INIT(msc);
msc.tx_for_mode_separate = tx_template;
bool r = get_ionic_swap_proposal_info(tx_template, msc.proposal);
wallet_public::ionic_swap_proposal_context ionic_context = AUTO_VAL_INIT(ionic_context);
bool r = get_ionic_swap_proposal_info(proposal, msc.proposal_info, ionic_context);
THROW_IF_TRUE_WALLET_EX(!r, error::wallet_internal_error, "Failed to get info from proposal");
std::unordered_map<crypto::public_key, wallet_public::asset_balance_entry_base> balances;
@ -5117,7 +5141,7 @@ bool wallet2::accept_ionic_swap_proposal(const currency::transaction& tx_templat
this->balance(balances, mined);
//validate balances needed
uint64_t native_amount_required = 0;
for (const auto& item : msc.proposal.to)
for (const auto& item : msc.proposal_info.to)
{
if (balances[item.asset_id].unlocked < item.amount)
{
@ -5131,9 +5155,9 @@ bool wallet2::accept_ionic_swap_proposal(const currency::transaction& tx_templat
// balances is ok, check if fee is added to tx
uint64_t additional_fee = 0;
if (msc.proposal.fee < m_core_runtime_config.tx_default_fee)
if (msc.proposal_info.fee < m_core_runtime_config.tx_default_fee)
{
additional_fee = m_core_runtime_config.tx_default_fee - msc.proposal.fee;
additional_fee = m_core_runtime_config.tx_default_fee - msc.proposal_info.fee;
if (balances[currency::native_coin_asset_id].unlocked < additional_fee + native_amount_required)
{
return false;
@ -5145,7 +5169,7 @@ bool wallet2::accept_ionic_swap_proposal(const currency::transaction& tx_templat
construct_tx_param construct_param = get_default_construct_tx_param();
construct_param.fee = additional_fee;
assert(0); crypto::secret_key one_time_key = currency::null_skey; //TODO: add transfer of secrete onetime key to proposal
assert(0); crypto::secret_key one_time_key = ionic_context.one_time_skey;
construct_param.crypt_address = m_account.get_public_address();
construct_param.flags = TX_FLAG_SIGNATURE_MODE_SEPARATE;
construct_param.mark_tx_as_complete = true;
@ -5153,6 +5177,7 @@ bool wallet2::accept_ionic_swap_proposal(const currency::transaction& tx_templat
//build transaction
currency::finalize_tx_param ftp = AUTO_VAL_INIT(ftp);
ftp.tx_version = this->get_current_tx_version();
ftp.gen_context = ionic_context.gen_context;
prepare_transaction(construct_param, ftp, msc);
try
@ -5165,8 +5190,6 @@ bool wallet2::accept_ionic_swap_proposal(const currency::transaction& tx_templat
throw;
}
mark_transfers_as_spent(ftp.selected_transfers, std::string("Proposal has been accepted with tx <" + epee::string_tools::pod_to_hex(get_transaction_hash(result_tx))) + ">");
return true;
}
//----------------------------------------------------------------------------------------------------
@ -6197,7 +6220,7 @@ void wallet2::prepare_transaction(construct_tx_param& ctp, currency::finalize_tx
if (ctp.flags & TX_FLAG_SIGNATURE_MODE_SEPARATE && tx_for_mode_separate.vout.size() )
{
WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(get_tx_flags(tx_for_mode_separate) & TX_FLAG_SIGNATURE_MODE_SEPARATE, "tx_param.flags differs from tx.flags");
for (const auto& el : mode_separatemode_separate.proposal.to)
for (const auto& el : mode_separatemode_separate.proposal_info.to)
{
needed_money_map[el.asset_id].needed_amount += el.amount;
}

View file

@ -949,15 +949,16 @@ namespace tools
bool check_htlc_redeemed(const crypto::hash& htlc_tx_id, std::string& origin, crypto::hash& redeem_tx_id);
// ionic swaps:
bool create_ionic_swap_proposal(const wallet_public::ionic_swap_proposal_info& proposal, const currency::account_public_address& destination_addr, currency::transaction& tx_template);
bool create_ionic_swap_proposal(const wallet_public::ionic_swap_proposal_info& proposal, const currency::account_public_address& destination_addr, ionic_swap_proposal& proposal);
bool build_ionic_swap_template(const wallet_public::ionic_swap_proposal_info& proposal_detais, const currency::account_public_address& destination_addr,
currency::transaction& template_tx,
ionic_swap_proposal& proposal,
std::vector<uint64_t>& selected_transfers_for_template,
crypto::secret_key& one_time_key);
bool get_ionic_swap_proposal_info(const std::string&raw_tx_template, wallet_public::ionic_swap_proposal_info& proposal);
bool get_ionic_swap_proposal_info(const currency::transaction tx, wallet_public::ionic_swap_proposal_info& proposal);
bool accept_ionic_swap_proposal(const std::string&raw_tx_template, currency::transaction& result_tx);
bool accept_ionic_swap_proposal(const currency::transaction& tx_template, currency::transaction& result_tx);
bool get_ionic_swap_proposal_info(const std::string&raw_proposal, wallet_public::ionic_swap_proposal_info& proposal_info);
bool get_ionic_swap_proposal_info(const wallet_public::ionic_swap_proposal& proposal, wallet_public::ionic_swap_proposal_info& proposal_info);
bool get_ionic_swap_proposal_info(const wallet_public::ionic_swap_proposal& proposal, wallet_public::ionic_swap_proposal_info& proposal_info, wallet_public::ionic_swap_proposal_context& ionic_context);
bool accept_ionic_swap_proposal(const std::string& raw_proposal, currency::transaction& result_tx);
bool accept_ionic_swap_proposal(const wallet_public::ionic_swap_proposal& proposal, currency::transaction& result_tx);
// Signing and auth
bool sign_buffer(const std::string& buff, crypto::signature& sig);
@ -970,8 +971,6 @@ private:
// -------- t_transport_state_notifier ------------------------------------------------
virtual void notify_state_change(const std::string& state_code, const std::string& details = std::string());
// ------------------------------------------------------------------------------------
void add_transfers_to_expiration_list(const std::vector<uint64_t>& selected_transfers, uint64_t expiration, uint64_t change_amount, const crypto::hash& related_tx_id);
void remove_transfer_from_expiration_list(uint64_t transfer_index);
void load_keys(const std::string& keys_file_name, const std::string& password, uint64_t file_signature, keys_file_data& kf_data);

View file

@ -1210,6 +1210,34 @@ namespace wallet_public
END_KV_SERIALIZE_MAP()
};
struct ionic_swap_proposal_context
{
currency::tx_generation_context gen_context;
crypto::secret_key one_time_skey;
BEGIN_SERIALIZE_OBJECT()
VERSION()
CURRENT_VERSION(0)
FIELD(gen_context)
FIELD(one_time_skey)
END_SERIALIZE()
};
struct ionic_swap_proposal
{
currency::transaction tx_template;
std::string encrypted_context; //ionic_swap_proposal_context encrypted with derivation
BEGIN_SERIALIZE_OBJECT()
VERSION()
CURRENT_VERSION(0)
FIELD(tx_template)
FIELD(encrypted_context)
END_SERIALIZE()
};
struct create_ionic_swap_proposal_request
{
uint64_t wallet_id;

View file

@ -885,15 +885,15 @@ std::string wallets_manager::create_ionic_swap_proposal(uint64_t wallet_id, cons
{
return API_RETURN_CODE_BAD_ARG;
}
currency::transaction tx_template = AUTO_VAL_INIT(tx_template);
bool r = wo.w->get()->create_ionic_swap_proposal(proposal.proposal, dest_account, tx_template);
tools::wallet_public ionic_swap_proposal proposal = AUTO_VAL_INIT(proposal);
bool r = wo.w->get()->create_ionic_swap_proposal(proposal.proposal, dest_account, proposal);
if (!r)
{
return API_RETURN_CODE_FAIL;
}
else
{
result_proposal_hex = epee::string_tools::buff_to_hex_nodelimer(t_serializable_object_to_blob(tx_template));
result_proposal_hex = epee::string_tools::buff_to_hex_nodelimer(t_serializable_object_to_blob(proposal));
return API_RETURN_CODE_OK;
}
}