forked from lthn/blockchain
extended wallet transfer API to service_entries option
This commit is contained in:
parent
232a6d71d0
commit
71c9069d27
5 changed files with 31 additions and 14 deletions
|
|
@ -387,7 +387,7 @@ namespace currency
|
|||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(service_id)
|
||||
KV_SERIALIZE(instruction)
|
||||
KV_SERIALIZE(body)
|
||||
KV_SERIALIZE_BLOB_AS_HEX_STRING(body)
|
||||
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(security)
|
||||
KV_SERIALIZE(flags)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
|
|
|
|||
|
|
@ -595,12 +595,12 @@ namespace tools
|
|||
void transfer(construct_tx_param& ctp,
|
||||
currency::transaction &tx,
|
||||
bool send_to_network,
|
||||
std::string* p_unsigned_filename_or_tx_blob_str);
|
||||
std::string* p_unsigned_filename_or_tx_blob_str = nullptr);
|
||||
|
||||
void transfer(construct_tx_param& ctp,
|
||||
currency::finalized_tx& result,
|
||||
bool send_to_network,
|
||||
std::string* p_unsigned_filename_or_tx_blob_str);
|
||||
std::string* p_unsigned_filename_or_tx_blob_str = nullptr);
|
||||
|
||||
|
||||
template<typename destination_split_strategy_t>
|
||||
|
|
@ -854,6 +854,7 @@ namespace tools
|
|||
uint64_t get_sync_progress();
|
||||
uint64_t get_wallet_file_size()const;
|
||||
void set_use_deffered_global_outputs(bool use);
|
||||
construct_tx_param get_default_construct_tx_param_inital();
|
||||
|
||||
/*
|
||||
create_htlc_proposal: if htlc_hash == null_hash, then this wallet is originator of the atomic process, and
|
||||
|
|
@ -943,7 +944,7 @@ private:
|
|||
void change_contract_state(wallet_public::escrow_contract_details_basic& contract, uint32_t new_state, const crypto::hash& contract_id, const wallet_public::wallet_transfer_info& wti) const;
|
||||
void change_contract_state(wallet_public::escrow_contract_details_basic& contract, uint32_t new_state, const crypto::hash& contract_id, const std::string& reason = "internal intention") const;
|
||||
|
||||
construct_tx_param get_default_construct_tx_param_inital();
|
||||
|
||||
const construct_tx_param& get_default_construct_tx_param();
|
||||
|
||||
uint64_t get_tx_expiration_median() const;
|
||||
|
|
|
|||
|
|
@ -388,16 +388,19 @@ namespace wallet_public
|
|||
std::string comment;
|
||||
bool push_payer;
|
||||
bool hide_receiver;
|
||||
std::vector<currency::tx_service_attachment> service_entries;
|
||||
bool service_entries_permanent;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(destinations)
|
||||
KV_SERIALIZE(fee)
|
||||
KV_SERIALIZE(mixin)
|
||||
//KV_SERIALIZE(unlock_time)
|
||||
KV_SERIALIZE(payment_id)
|
||||
KV_SERIALIZE(comment)
|
||||
KV_SERIALIZE(push_payer)
|
||||
KV_SERIALIZE(hide_receiver)
|
||||
KV_SERIALIZE(service_entries)
|
||||
KV_SERIALIZE(service_entries_permanent)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -281,7 +281,18 @@ namespace tools
|
|||
return false;
|
||||
}
|
||||
|
||||
std::vector<currency::tx_destination_entry> dsts;
|
||||
construct_tx_param ctp = m_wallet.get_default_construct_tx_param_inital();
|
||||
if (req.service_entries_permanent)
|
||||
{
|
||||
//put it to extra
|
||||
ctp.extra.insert(ctp.extra.end(), req.service_entries.begin(), req.service_entries.end());
|
||||
}
|
||||
else
|
||||
{
|
||||
//put it to attachments
|
||||
ctp.attachments.insert(ctp.extra.end(), req.service_entries.begin(), req.service_entries.end());
|
||||
}
|
||||
std::vector<currency::tx_destination_entry>& dsts = ctp.dsts;
|
||||
for (auto it = req.destinations.begin(); it != req.destinations.end(); it++)
|
||||
{
|
||||
currency::tx_destination_entry de;
|
||||
|
|
@ -308,8 +319,8 @@ namespace tools
|
|||
}
|
||||
try
|
||||
{
|
||||
std::vector<currency::attachment_v> attachments;
|
||||
std::vector<currency::extra_v> extra;
|
||||
std::vector<currency::attachment_v>& attachments = ctp.attachments;
|
||||
std::vector<currency::extra_v>& extra = ctp.extra;
|
||||
if (!payment_id.empty() && !currency::set_payment_id_to_tx(attachments, payment_id))
|
||||
{
|
||||
er.code = WALLET_RPC_ERROR_CODE_WRONG_PAYMENT_ID;
|
||||
|
|
@ -338,10 +349,11 @@ namespace tools
|
|||
}
|
||||
}
|
||||
|
||||
currency::transaction tx;
|
||||
|
||||
currency::finalized_tx result = AUTO_VAL_INIT(result);
|
||||
std::string unsigned_tx_blob_str;
|
||||
m_wallet.transfer(dsts, req.mixin, 0/*req.unlock_time*/, req.fee, extra, attachments, detail::ssi_digit, tx_dust_policy(DEFAULT_DUST_THRESHOLD), tx, CURRENCY_TO_KEY_OUT_RELAXED, true, 0, true, &unsigned_tx_blob_str);
|
||||
ctp.fee = req.fee;
|
||||
ctp.fake_outputs_count = 0;
|
||||
m_wallet.transfer(ctp, result, true, &unsigned_tx_blob_str);
|
||||
if (m_wallet.is_watch_only())
|
||||
{
|
||||
res.tx_unsigned_hex = epee::string_tools::buff_to_hex_nodelimer(unsigned_tx_blob_str); // watch-only wallets could not sign and relay transactions
|
||||
|
|
@ -349,8 +361,8 @@ namespace tools
|
|||
}
|
||||
else
|
||||
{
|
||||
res.tx_hash = epee::string_tools::pod_to_hex(currency::get_transaction_hash(tx));
|
||||
res.tx_size = get_object_blobsize(tx);
|
||||
res.tx_hash = epee::string_tools::pod_to_hex(currency::get_transaction_hash(result.tx));
|
||||
res.tx_size = get_object_blobsize(result.tx);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
#define BC_WRAP_SERVICE_ID "W"
|
||||
|
||||
#define BC_WRAP_SERVICE_INSTRUCTION_ERC20 "ERC20" //erc20 wrapped operation
|
||||
#define BC_WRAP_SERVICE_INSTRUCTION_ERC20 "ERC20" //erc20 wrap operation
|
||||
#define BC_WRAP_SERVICE_INSTRUCTION_UNWRAP "UNWRAP" //erc20 unwrap operation
|
||||
|
||||
|
||||
#define BC_WRAP_SERVICE_CUSTODY_WALLET "aZxbJPXzkjCJDpGEVvkMir9B4fRKPo73r2e5D7nLHuVgEBXXQYc2Tk2hHroxVwiCDLDHZu215pgNocUsrchH4HHzWbHzL4nMfPq"
|
||||
Loading…
Add table
Reference in a new issue