This commit is contained in:
woodser
2020-03-01 17:31:15 -05:00
parent 500667049e
commit 14e88687c7
4 changed files with 30 additions and 35 deletions
+2 -2
View File
@@ -11,7 +11,7 @@ This library may be used to build Monero-related applications, such as GUIs, lib
## Main Features
- Manage Monero wallets which connect to a daemon
- Cohesive APIs and models with rigorous focus on ease-of-use
- Cohesive APIs and models with focus on ease-of-use
- Query wallet transactions, transfers, and outputs by their attributes
- Be notified when blocks are added to the chain, as the wallet synchronizes, or when the wallet sends or receives funds
- Full multisig support
@@ -187,7 +187,7 @@ This project is licensed under MIT.
## Donate
If you get value from this library, please consider donating. Thank you.
If you get value from this library, please consider donating. Thank you!
<p align="center">
<img src="donate.png" width="115" height="115"/>
+2 -19
View File
@@ -1159,23 +1159,14 @@ namespace monero {
* Check a transaction in the blockchain with its secret key.
*
* @param tx_hash specifies the transaction to check
* @param txKey is the transaction's secret key
* @param tx_key is the transaction's secret key
* @param address is the destination public address of the transaction
* @return the result of the check
*/
virtual shared_ptr<monero_check_tx> check_tx_key(const string& tx_hash, const string& txKey, const string& address) const {
virtual shared_ptr<monero_check_tx> check_tx_key(const string& tx_hash, const string& tx_key, const string& address) const {
throw runtime_error("check_tx_key() not supported");
}
// /**
// * Get a transaction signature to prove it.
// *
// * @param tx_hash specifies the transaction to prove
// * @param address is the destination public address of the transaction
// * @return the transaction signature
// */
// string get_tx_proof(const string& tx_hash, const string& address) const;
/**
* Get a transaction signature to prove it.
*
@@ -1201,14 +1192,6 @@ namespace monero {
throw runtime_error("check_tx_proof() not supported");
}
// /**
// * Generate a signature to prove a spend. Unlike proving a transaction, it does not require the destination public address.
// *
// * @param tx_hash specifies the transaction to prove
// * @return the transaction signature
// */
// string get_spend_proof(const string& tx_hash) const;
/**
* Generate a signature to prove a spend. Unlike proving a transaction, it does not require the destination public address.
*
+25 -13
View File
@@ -2579,22 +2579,28 @@ namespace monero {
shared_ptr<monero_check_tx> monero_wallet_core::check_tx_key(const string& tx_hash, const string& tx_key, const string& address) const {
MTRACE("monero_wallet_core::check_tx_key()");
cout << "check tx key 1" << endl;
// validate and parse tx hash
crypto::hash _tx_hash;
if (!epee::string_tools::hex_to_pod(tx_hash, _tx_hash)) {
throw runtime_error("TX hash has invalid format");
}
cout << "check tx key 2" << endl;
// validate and parse tx key
epee::wipeable_string tx_key_str = tx_key;
if (tx_key_str.size() < 64 || tx_key_str.size() % 64) {
throw runtime_error("Tx key has invalid format");
}
cout << "check tx key 3" << endl;
const char *data = tx_key_str.data();
crypto::secret_key _tx_key;
if (!epee::wipeable_string(data, 64).hex_to_pod(unwrap(unwrap(_tx_key)))) {
throw runtime_error("Tx key has invalid format");
}
cout << "check tx key 4" << endl;
// get additional keys
size_t offset = 64;
@@ -2606,24 +2612,30 @@ namespace monero {
}
offset += 64;
}
cout << "check tx key 5" << endl;
// validate and parse address
cryptonote::address_parse_info info;
if (!get_account_address_from_str(info, m_w2->nettype(), address)) {
throw runtime_error("Invalid address");
}
cout << "check tx key 6" << endl;
// initialize and return tx check using wallet2
uint64_t received_amount;
bool in_tx_pool;
uint64_t num_confirmations;
cout << "check tx key 7" << endl;
m_w2->check_tx_key(_tx_hash, _tx_key, additional_tx_keys, info.address, received_amount, in_tx_pool, num_confirmations);
shared_ptr<monero_check_tx> checkTx = make_shared<monero_check_tx>();
checkTx->m_is_good = true; // check is good if we get this far
checkTx->m_received_amount = received_amount;
checkTx->m_in_tx_pool = in_tx_pool;
checkTx->m_num_confirmations = num_confirmations;
return checkTx;
cout << "check tx key 8" << endl;
shared_ptr<monero_check_tx> check_tx = make_shared<monero_check_tx>();
cout << "check tx key 9" << endl;
check_tx->m_is_good = true; // check is good if we get this far
check_tx->m_received_amount = received_amount;
check_tx->m_in_tx_pool = in_tx_pool;
check_tx->m_num_confirmations = num_confirmations;
cout << "check tx key 10" << endl;
return check_tx;
}
string monero_wallet_core::get_tx_proof(const string& tx_hash, const string& address, const string& message) const {
@@ -2660,17 +2672,17 @@ namespace monero {
}
// initialize and return tx check using wallet2
shared_ptr<monero_check_tx> checkTx = make_shared<monero_check_tx>();
shared_ptr<monero_check_tx> check_tx = make_shared<monero_check_tx>();
uint64_t received_amount;
bool in_tx_pool;
uint64_t num_confirmations;
checkTx->m_is_good = m_w2->check_tx_proof(_tx_hash, info.address, info.is_subaddress, message, signature, received_amount, in_tx_pool, num_confirmations);
if (checkTx->m_is_good) {
checkTx->m_received_amount = received_amount;
checkTx->m_in_tx_pool = in_tx_pool;
checkTx->m_num_confirmations = num_confirmations;
check_tx->m_is_good = m_w2->check_tx_proof(_tx_hash, info.address, info.is_subaddress, message, signature, received_amount, in_tx_pool, num_confirmations);
if (check_tx->m_is_good) {
check_tx->m_received_amount = received_amount;
check_tx->m_in_tx_pool = in_tx_pool;
check_tx->m_num_confirmations = num_confirmations;
}
return checkTx;
return check_tx;
}
string monero_wallet_core::get_spend_proof(const string& tx_hash, const string& message) const {
+1 -1
View File
@@ -87,7 +87,7 @@ int main(int argc, const char* argv[]) {
uint64_t random_height = wallet_random->get_height();
bool random_is_synced = wallet_random->is_synced();
// be notified when the wallet receives funds
// receive notifications when the wallet receives funds
struct : monero_wallet_listener {
void on_output_received(const monero_output_wallet& output) {
cout << "Wallet received funds!" << endl;