43 #include <boost/format.hpp> 49 PendingTransaction::~PendingTransaction() {}
52 PendingTransactionImpl::PendingTransactionImpl(
WalletImpl &wallet)
75 std::vector<std::string>
txid;
76 for (
const auto &pt: m_pending_tx)
84 LOG_PRINT_L3(
"m_pending_tx size: " << m_pending_tx.size());
88 if (!filename.empty()) {
89 boost::system::error_code ignore;
90 bool tx_file_exists = boost::filesystem::exists(filename, ignore);
91 if(tx_file_exists && !overwrite){
92 m_errorString =
string(
tr(
"Attempting to save transaction to file, but specified file(s) exist. Exiting to not risk overwriting. File:")) + filename;
97 bool r = m_wallet.m_wallet->save_tx(m_pending_tx, filename);
99 m_errorString =
tr(
"Failed to write transaction(s) to file");
107 auto multisigState = m_wallet.
multisig();
108 if (multisigState.isMultisig && m_signers.size() < multisigState.threshold) {
109 throw runtime_error(
"Not enough signers to send multisig transaction");
114 const bool tx_cold_signed = m_wallet.m_wallet->get_account().get_device().has_tx_cold_sign();
116 std::unordered_set<size_t> selected_transfers;
118 for(
size_t s : ptx.selected_transfers){
119 selected_transfers.insert(s);
123 m_wallet.m_wallet->cold_tx_aux_import(m_pending_tx, m_tx_device_aux);
124 bool r = m_wallet.m_wallet->import_key_images(m_key_images, 0, selected_transfers);
126 throw runtime_error(
"Cold sign transaction submit failed - key image sync fail");
130 while (!m_pending_tx.empty()) {
131 auto & ptx = m_pending_tx.back();
132 m_wallet.m_wallet->commit_tx(ptx);
134 m_pending_tx.pop_back();
139 m_errorString =
tr(
"daemon is busy. Please try again later.");
142 m_errorString =
tr(
"no connection to daemon. Please make sure daemon is running.");
145 std::ostringstream writer(m_errorString);
149 m_errorString = writer.str();
151 m_errorString +=
string(
tr(
". Reason: ")) + reason;
152 }
catch (
const std::exception &e) {
153 m_errorString =
string(
tr(
"Unknown exception: ")) + e.what();
156 m_errorString =
tr(
"Unhandled exception");
168 for (
const auto &ptx : m_pending_tx) {
169 for (
const auto &
dest : ptx.dests) {
170 result +=
dest.amount;
179 for (
const auto & ptx : m_pending_tx) {
188 for (
const auto &ptx : m_pending_tx) {
196 return m_pending_tx.size();
201 std::vector<uint32_t> result;
202 for (
const auto& ptx : m_pending_tx)
203 result.push_back(ptx.construction_data.subaddr_account);
209 std::vector<std::set<uint32_t>> result;
210 for (
const auto& ptx : m_pending_tx)
211 result.push_back(ptx.construction_data.subaddr_indices);
218 throw std::runtime_error(
"wallet is not multisig");
222 txSet.
m_ptx = m_pending_tx;
224 auto cipher = m_wallet.m_wallet->save_multisig_tx(txSet);
227 }
catch (
const std::exception& e) {
229 m_errorString =
std::string(
tr(
"Couldn't multisig sign data: ")) + e.what();
237 std::vector<crypto::hash> ignore;
240 txSet.
m_ptx = m_pending_tx;
243 if (!m_wallet.m_wallet->sign_multisig_tx(txSet, ignore)) {
244 throw std::runtime_error(
"couldn't sign multisig transaction");
247 std::swap(m_pending_tx, txSet.
m_ptx);
249 }
catch (
const std::exception& e) {
251 m_errorString =
std::string(
tr(
"Couldn't sign multisig transaction: ")) + e.what();
256 std::vector<std::string> keys;
257 keys.reserve(m_signers.size());
259 for (
const auto& signer: m_signers) {
void signMultisigTx() override
std::string errorString() const override
uint64_t txCount() const override
txCount - number of transactions current transaction will be splitted to
CXA_THROW_INFO_T void(* dest)(void *))
virtual void startRefresh() override
StartRefresh - Start/resume refresh thread (refresh every 10 seconds)
std::vector< std::string > signersKeys() const override
signersKeys
~PendingTransactionImpl()
std::vector< uint32_t > subaddrAccount() const override
virtual void pauseRefresh() override
pauseRefresh - pause refresh thread
bool commit(const std::string &filename="", bool overwrite=false) override
std::vector< std::set< uint32_t > > subaddrIndices() const override
unsigned __int64 uint64_t
bool t_serializable_object_to_blob(const t_object &to, blobdata &b_blob)
MultisigState multisig() const override
multisig - returns current state of multisig wallet creation process
int status() const override
uint64_t fee() const override
uint64_t amount() const override
std::string multisigSignData() override
multisigSignData
crypto::hash get_transaction_hash(const transaction &t)
std::vector< std::string > txid() const override
uint64_t dust() const override