added tx_key to create_transaction ret vals

pull/29/head
Paul Shapiro 6 years ago
parent 30d08919b0
commit 9a9d9cb8f0

@ -543,6 +543,8 @@ void monero_transfer_utils::create_transaction(
THROW_WALLET_EXCEPTION_IF(use_bulletproofs != bulletproof, error::wallet_internal_error, "Expected tx use_bulletproofs to equal bulletproof flag");
//
retVals.tx = tx;
retVals.tx_key = tx_key;
retVals.additional_tx_keys = additional_tx_keys;
}
//
//
@ -653,13 +655,23 @@ void monero_transfer_utils::convenience__create_transaction(
retVals.errCode = actualCall_retVals.errCode; // pass-through
return; // already set the error
}
auto txBlob = t_serializable_object_to_blob(actualCall_retVals.tx);
auto txBlob = t_serializable_object_to_blob(*actualCall_retVals.tx);
size_t txBlob_byteLength = txBlob.size();
// cout << "txBlob: " << txBlob << endl;
cout << "txBlob_byteLength: " << txBlob_byteLength << endl;
THROW_WALLET_EXCEPTION_IF(txBlob_byteLength <= 0, error::wallet_internal_error, "Expected tx blob byte length > 0");
//
// tx hash
retVals.tx_hash_string = epee::string_tools::pod_to_hex(cryptonote::get_transaction_hash(actualCall_retVals.tx));
retVals.signed_serialized_tx_string = epee::string_tools::buff_to_hex_nodelimer(cryptonote::tx_to_blob(actualCall_retVals.tx));
retVals.tx_hash_string = epee::string_tools::pod_to_hex(cryptonote::get_transaction_hash(*actualCall_retVals.tx));
// signed serialized tx
retVals.signed_serialized_tx_string = epee::string_tools::buff_to_hex_nodelimer(cryptonote::tx_to_blob(*actualCall_retVals.tx));
// (concatenated) tx key
ostringstream oss;
{
oss << epee::string_tools::pod_to_hex(*actualCall_retVals.tx_key);
for (size_t i = 0; i < (*actualCall_retVals.additional_tx_keys).size(); ++i) {
oss << epee::string_tools::pod_to_hex((*actualCall_retVals.additional_tx_keys)[i]);
}
}
retVals.tx_key_string = oss.str();
}

@ -175,7 +175,9 @@ namespace monero_transfer_utils
{
CreateTransactionErrorCode errCode;
//
cryptonote::transaction tx;
optional<transaction> tx;
optional<secret_key> tx_key;
optional<vector<secret_key>> additional_tx_keys;
};
// TODO: add priority
void create_transaction(
@ -200,6 +202,7 @@ namespace monero_transfer_utils
//
optional<string> signed_serialized_tx_string;
optional<string> tx_hash_string;
optional<string> tx_key_string; // this includes additional_tx_keys
};
void convenience__create_transaction(
Convenience_TransactionConstruction_RetVals &retVals,

@ -549,6 +549,7 @@ string serial_bridge::create_transaction(const string &args_string)
boost::property_tree::ptree root;
root.put(ret_json_key__create_transaction__serialized_signed_tx(), std::move(*(retVals.signed_serialized_tx_string)));
root.put(ret_json_key__create_transaction__tx_hash(), std::move(*(retVals.tx_hash_string)));
root.put(ret_json_key__create_transaction__tx_key(), std::move(*(retVals.tx_key_string)));
//
return ret_json_from_root(root);
}

@ -77,6 +77,7 @@ namespace serial_bridge
// - - create_transaction
static inline string ret_json_key__create_transaction__serialized_signed_tx() { return "serialized_signed_tx"; }
static inline string ret_json_key__create_transaction__tx_hash() { return "tx_hash"; }
static inline string ret_json_key__create_transaction__tx_key() { return "tx_key"; }
// - - decode_address, etc
static inline string ret_json_key__paymentID_string() { return "paymentID_string"; } // optional
static inline string ret_json_key__isSubaddress() { return "isSubaddress"; }

@ -303,16 +303,16 @@ BOOST_AUTO_TEST_CASE(transfers__create)
BOOST_REQUIRE_MESSAGE(false, "create_transaction failed");
return;
}
auto txBlob = t_serializable_object_to_blob(retVals.tx);
auto txBlob = t_serializable_object_to_blob(*retVals.tx);
size_t txBlob_byteLength = txBlob.size();
// cout << "txBlob: " << txBlob << endl;
cout << "transfers__create: txBlob_byteLength: " << txBlob_byteLength << endl;
BOOST_REQUIRE(txBlob_byteLength > 0);
// tx hash
auto tx_hash_string = epee::string_tools::pod_to_hex(cryptonote::get_transaction_hash(retVals.tx));
auto signed_serialized_tx_string = epee::string_tools::buff_to_hex_nodelimer(cryptonote::tx_to_blob(retVals.tx));
auto tx_hash_string = epee::string_tools::pod_to_hex(cryptonote::get_transaction_hash(*retVals.tx));
auto signed_serialized_tx_string = epee::string_tools::buff_to_hex_nodelimer(cryptonote::tx_to_blob(*retVals.tx));
cout << "transfers__create: tx_hash_string: " << tx_hash_string << endl;
cout << "transfers__create: signed_serialized_tx_string: " << signed_serialized_tx_string << endl;
}
@ -450,6 +450,7 @@ BOOST_AUTO_TEST_CASE(bridged__transfers__create)
BOOST_REQUIRE_MESSAGE(false, err_msg);
}
optional<string> tx_hash = ret_tree.get_optional<string>(ret_json_key__create_transaction__tx_hash());
optional<string> tx_key_string = ret_tree.get_optional<string>(ret_json_key__create_transaction__tx_key());
optional<string> serialized_signed_tx = ret_tree.get_optional<string>(ret_json_key__create_transaction__serialized_signed_tx());
BOOST_REQUIRE(serialized_signed_tx != none);
BOOST_REQUIRE((*serialized_signed_tx).size() > 0);
@ -457,6 +458,9 @@ BOOST_AUTO_TEST_CASE(bridged__transfers__create)
BOOST_REQUIRE(tx_hash != none);
BOOST_REQUIRE((*tx_hash).size() > 0);
cout << "bridged__transfers__create: tx_hash: " << *tx_hash << endl;
BOOST_REQUIRE(tx_key_string != none);
BOOST_REQUIRE((*tx_key_string).size() > 0);
cout << "bridged__transfers__create: tx_key_string: " << *tx_key_string << endl;
}
//
BOOST_AUTO_TEST_CASE(bridged__decode_address)

Loading…
Cancel
Save