mirror of
https://github.com/wownero/wownero-cpp.git
synced 2026-10-17 15:21:30 +02:00
shared_ptr<MoneroTx> cnTxToTx(const cryptonote::transaction& cnTx, bool
initAsTxWallet = false);
This commit is contained in:
@@ -479,15 +479,15 @@ shared_ptr<MoneroBlock> MoneroUtils::cnBlockToBlock(const cryptonote::block& cnB
|
||||
block->timestamp = cnBlock.timestamp;
|
||||
block->prevId = epee::string_tools::pod_to_hex(cnBlock.prev_id);
|
||||
block->nonce = cnBlock.nonce;
|
||||
block->coinbaseTx = MoneroUtils::cnTransactionToTx(cnBlock.miner_tx);
|
||||
block->coinbaseTx = MoneroUtils::cnTxToTx(cnBlock.miner_tx);
|
||||
for (const crypto::hash& txHash : cnBlock.tx_hashes) {
|
||||
block->txIds.push_back(epee::string_tools::pod_to_hex(txHash));
|
||||
}
|
||||
return block;
|
||||
}
|
||||
|
||||
shared_ptr<MoneroTx> MoneroUtils::cnTransactionToTx(const cryptonote::transaction& cnTx) {
|
||||
shared_ptr<MoneroTx> tx = make_shared<MoneroTx>();
|
||||
shared_ptr<MoneroTx> MoneroUtils::cnTxToTx(const cryptonote::transaction& cnTx, bool initAsTxWallet) {
|
||||
shared_ptr<MoneroTx> tx = initAsTxWallet ? make_shared<MoneroTxWallet>() : make_shared<MoneroTx>();
|
||||
//tx->version = cnTx.version;
|
||||
tx->unlockTime = cnTx.unlock_time;
|
||||
tx->id = epee::string_tools::pod_to_hex(cnTx.hash);
|
||||
|
||||
@@ -92,13 +92,15 @@ namespace MoneroUtils
|
||||
*/
|
||||
shared_ptr<MoneroBlock> cnBlockToBlock(const cryptonote::block& cnBlock);
|
||||
|
||||
|
||||
/**
|
||||
* Convert a Monero Core cryptonote::transaction to a transaction in this library's native model.
|
||||
* Convert a Monero Core crpytonote::transaction to a transaction in this library's
|
||||
* native model.
|
||||
*
|
||||
* @param cnTransaction is the Core transaction to convert
|
||||
* @return a transaction in this library's native model
|
||||
* @param cnTx is the Core transaction to convert
|
||||
* @param initAsTxWallet specifies if a MoneroTx xor MoneroTxWallet should be initialized
|
||||
*/
|
||||
shared_ptr<MoneroTx> cnTransactionToTx(const cryptonote::transaction& cnTransaction);
|
||||
shared_ptr<MoneroTx> cnTxToTx(const cryptonote::transaction& cnTx, bool initAsTxWallet = false);
|
||||
|
||||
/**
|
||||
* Modified from core_rpc_server.cpp to return a string.
|
||||
|
||||
@@ -719,14 +719,17 @@ namespace monero {
|
||||
// TODO **: fill this out
|
||||
shared_ptr<MoneroBlock> block = make_shared<MoneroBlock>();
|
||||
block->height = height;
|
||||
shared_ptr<MoneroTxWallet> tx = make_shared<MoneroTxWallet>();
|
||||
shared_ptr<MoneroTxWallet> tx = static_pointer_cast<MoneroTxWallet>(MoneroUtils::cnTxToTx(cnTx, true));
|
||||
block->txs.push_back(tx);
|
||||
tx->block = block;
|
||||
tx->id = epee::string_tools::pod_to_hex(txid);
|
||||
tx->unlockTime = unlock_time;
|
||||
shared_ptr<MoneroIncomingTransfer> transfer = make_shared<MoneroIncomingTransfer>();
|
||||
tx->incomingTransfers.push_back(transfer);
|
||||
transfer->tx = tx;
|
||||
transfer->amount = amount;
|
||||
transfer->accountIndex = subaddr_index.major;
|
||||
transfer->subaddressIndex = subaddr_index.minor;
|
||||
|
||||
// notify listener of transfer
|
||||
listener->onIncomingTransfer(*transfer);
|
||||
|
||||
Reference in New Issue
Block a user