monero_destination(address, amount) constructor;

sample_code compiling;
some convenience send methods impl
This commit is contained in:
woodser
2019-08-09 14:04:32 -04:00
parent f596067a3f
commit 493a3beb17
5 changed files with 50 additions and 13 deletions
+22 -6
View File
@@ -1694,24 +1694,36 @@ namespace monero {
return result;
}
shared_ptr<monero_tx_wallet> monero_wallet::create_tx(monero_send_request& request) {
if (request.m_can_split != boost::none && request.m_can_split.get()) throw runtime_error("Cannot request split transactions with create_tx() which prevents splitting; use create_txs() instead");
request.m_can_split = false;
return create_txs(request)[0];
}
shared_ptr<monero_tx_wallet> monero_wallet::create_tx(uint32_t account_index, string address, uint64_t amount) {
throw new runtime_error("create_tx not implemented");
return create_tx(account_index, address, amount, monero_send_priority::NORMAL);
}
shared_ptr<monero_tx_wallet> monero_wallet::create_tx(int account_index, string address, uint64_t amount, monero_send_priority priority) {
throw new runtime_error("create_tx not implemented");
monero_send_request req;
req.m_account_index = account_index;
req.m_destinations.push_back(make_shared<monero_destination>(address, amount));
req.m_priority = priority;
return create_tx(req);
}
shared_ptr<monero_tx_wallet> monero_wallet::create_tx(const monero_send_request& request) {
throw new runtime_error("create_tx not implemented");
vector<shared_ptr<monero_tx_wallet>> monero_wallet::create_txs(const monero_send_request& request) {
throw new runtime_error("not implemented");
}
string monero_wallet::relay_tx(const string& tx_metadata) {
throw new runtime_error("relay_tx not implemented");
vector<string> tx_metadatas;
tx_metadatas.push_back(tx_metadata);
return relay_txs(tx_metadatas)[0];
}
string monero_wallet::relay_tx(const monero_tx_wallet& tx) {
throw new runtime_error("relay_tx not implemented");
return relay_tx(tx.m_metadata.get());
}
vector<string> monero_wallet::relay_txs(const vector<string>& tx_metadatas) {
@@ -1756,6 +1768,10 @@ namespace monero {
throw new runtime_error("relay_txs not implemented");
}
shared_ptr<monero_tx_wallet> monero_wallet::send(monero_send_request& request) {
throw new runtime_error("send not implemented");
}
shared_ptr<monero_tx_wallet> monero_wallet::send(uint32_t account_index, string address, uint64_t amount) {
throw new runtime_error("send not implemented");
}
+23 -5
View File
@@ -745,6 +745,15 @@ namespace monero {
// */
// public List<monero_key_image> getNewKeyImagesFromLastImport();
/**
* Create a transaction to transfer funds from this wallet according to the
* given request. The transaction may be relayed later.
*
* @param request configures the transaction to create
* @return the created transaction
*/
shared_ptr<monero_tx_wallet> create_tx(monero_send_request& request);
/**
* Create a transaction to transfers funds from this wallet to a destination address.
* The transaction may be relayed later.
@@ -769,13 +778,13 @@ namespace monero {
shared_ptr<monero_tx_wallet> create_tx(int account_index, string address, uint64_t amount, monero_send_priority priority);
/**
* Create a transaction to transfer funds from this wallet according to the
* given request. The transaction may be relayed later.
* Create one or more transactions to transfer funds from this wallet
* according to the given request. The transactions may later be relayed.
*
* @param request configures the transaction to create
* @return the created transaction
* @param request configures the transactions to create
* @return the created transactions
*/
shared_ptr<monero_tx_wallet> create_tx(const monero_send_request& request);
vector<shared_ptr<monero_tx_wallet>> create_txs(const monero_send_request& request);
/**
* Relay a transaction previously created without relaying.
@@ -809,6 +818,15 @@ namespace monero {
*/
vector<string> relay_txs(const vector<monero_tx_wallet>& txs);
/**
* Create and relay a transaction to transfer funds from this wallet
* according to the given request.
*
* @param request configures the transaction
* @return the resulting transaction
*/
shared_ptr<monero_tx_wallet> send(monero_send_request& request);
/**
* Create and relay a transaction to transfers funds from this wallet to
* a destination address.
+2
View File
@@ -135,6 +135,8 @@ namespace monero {
boost::optional<string> m_address;
boost::optional<uint64_t> m_amount;
monero_destination() {}
monero_destination(const string& address, uint64_t amount) : m_address(address), m_amount(amount) {}
shared_ptr<monero_destination> copy(const shared_ptr<monero_destination>& src, const shared_ptr<monero_destination>& tgt) const;
boost::property_tree::ptree to_property_tree() const;
};
+2 -2
View File
@@ -95,8 +95,8 @@ int main(int argc, const char* argv[]) {
send_request.m_subaddress_indices.push_back(1); // withdraw funds from these subaddresses within the account
send_request.m_priority = monero_send_priority::UNIMPORTANT; // no rush
vector<shared_ptr<monero_destination>> destinations; // specify the recipients and their amounts
// destinations.push_back(make_shared<monero_destination>(wallet_random->get_address(1, 0), 50000)); // TODO: destination constructor
// destinations.push_back(make_shared<monero_destination>(wallet_random->get_address(2, 0), 50000));
destinations.push_back(make_shared<monero_destination>(wallet_random->get_address(1, 0), 50000));
destinations.push_back(make_shared<monero_destination>(wallet_random->get_address(2, 0), 50000));
send_request.m_destinations = destinations;
// create the transaction, confirm with the user, and relay to the network
+1
View File
@@ -5,6 +5,7 @@ sample code including readme
monero_wallet_listener should be a class?
MEDIUM PRIORITY
create_tx and send_tx request arg should be const; need to copy
should not need wallet.h / wallet.cpp as dependency, why are GUI deps needed?
make model fields private and use accessors / mutators?
remove jstring2string, be consistent with other string inits