deserialization of unsigined tx data

This commit is contained in:
moneroexamples 2016-09-28 10:21:14 +08:00
parent 2ebc9eda37
commit 2d7f1854f9
3 changed files with 54 additions and 0 deletions

View File

@ -73,6 +73,10 @@ add_library(ringct STATIC IMPORTED)
set_property(TARGET ringct set_property(TARGET ringct
PROPERTY IMPORTED_LOCATION ${MONERO_LIBS_DIR}/libringct.a) PROPERTY IMPORTED_LOCATION ${MONERO_LIBS_DIR}/libringct.a)
add_library(wallet STATIC IMPORTED)
set_property(TARGET wallet
PROPERTY IMPORTED_LOCATION ${MONERO_LIBS_DIR}/libwallet.a)
# include boost headers # include boost headers
include_directories(${Boost_INCLUDE_DIRS}) include_directories(${Boost_INCLUDE_DIRS})
include_directories("ext/mstch/include") include_directories("ext/mstch/include")
@ -118,6 +122,7 @@ target_link_libraries(${PROJECT_NAME}
myxrm myxrm
myext myext
mstch mstch
wallet
cryptonote_core cryptonote_core
blockchain_db blockchain_db
crypto crypto

View File

@ -9,6 +9,10 @@
#define BLOCKCHAIN_DB DB_LMDB #define BLOCKCHAIN_DB DB_LMDB
#define UNSIGNED_TX_PREFIX "Monero unsigned tx set\001"
#define SIGNED_TX_PREFIX "Monero signed tx set\001"
#include "net/http_base.h" #include "net/http_base.h"
#include "net/http_server_handlers_map2.h" #include "net/http_server_handlers_map2.h"
#include "net/http_client.h" #include "net/http_client.h"
@ -19,12 +23,18 @@
#include "cryptonote_core/blockchain.h" #include "cryptonote_core/blockchain.h"
#include "blockchain_db/lmdb/db_lmdb.h" #include "blockchain_db/lmdb/db_lmdb.h"
#include "wallet/wallet2.h"
#include "serialization/binary_utils.h"
#include "ringct/rctTypes.h" #include "ringct/rctTypes.h"
#include "ringct/rctOps.h" #include "ringct/rctOps.h"
#include "ringct/rctSigs.h" #include "ringct/rctSigs.h"
#include "common/base58.h" #include "common/base58.h"
#include "string_coding.h"
#endif //XMREG01_MONERO_HEADERS_H_H #endif //XMREG01_MONERO_HEADERS_H_H

View File

@ -1531,8 +1531,47 @@ namespace xmreg {
string string
show_checkandpushtx(string raw_tx_data, string action) show_checkandpushtx(string raw_tx_data, string action)
{ {
// remove white characters
boost::trim(raw_tx_data);
boost::erase_all(raw_tx_data, "\r\n");
boost::erase_all(raw_tx_data, "\n");
cout << raw_tx_data << endl; cout << raw_tx_data << endl;
string decoded_raw_tx_data = epee::string_encoding::base64_decode(raw_tx_data);
cout << decoded_raw_tx_data << endl;
const size_t magiclen = strlen(UNSIGNED_TX_PREFIX);
bool unsigned_tx_given {false};
if (strncmp(decoded_raw_tx_data.c_str(), UNSIGNED_TX_PREFIX, magiclen) == 0)
{
unsigned_tx_given = true;
cout << "UNSIGNED_TX_PREFIX data given" << endl;
}
if (unsigned_tx_given)
{
::tools::wallet2::unsigned_tx_set exported_txs;
bool r = serialization::parse_binary(std::string(
decoded_raw_tx_data.c_str() + magiclen,
decoded_raw_tx_data.size() - magiclen),
exported_txs);
if (r)
{
}
else
{
cout << "deserialization of unsigined tx data NOT sucessful" << endl;
return string("deserialization of unsigined tx data NOT successful. "
"Maybe its not base64 encoded?");
}
}
cout << action << endl; cout << action << endl;
return {}; return {};