mirror of
https://github.com/wownero/wownero-cpp.git
synced 2026-10-25 02:58:37 +02:00
wip converting camelcase to underscores
This commit is contained in:
+117
-117
@@ -92,19 +92,19 @@ namespace monero {
|
||||
if (timestamp != boost::none) node.put("timestamp", *timestamp);
|
||||
if (size != boost::none) node.put("size", *size);
|
||||
if (weight != boost::none) node.put("weight", *weight);
|
||||
if (longTermWeight != boost::none) node.put("longTermWeight", *longTermWeight);
|
||||
if (long_term_weight != boost::none) node.put("long_term_weight", *long_term_weight);
|
||||
if (depth != boost::none) node.put("depth", *depth);
|
||||
if (difficulty != boost::none) node.put("difficulty", *difficulty);
|
||||
if (cumulativeDifficulty != boost::none) node.put("cumulativeDifficulty", *height);
|
||||
if (majorVersion != boost::none) node.put("majorVersion", *majorVersion);
|
||||
if (minorVersion != boost::none) node.put("minorVersion", *minorVersion);
|
||||
if (cumulative_difficulty != boost::none) node.put("cumulative_difficulty", *height);
|
||||
if (major_version != boost::none) node.put("major_version", *major_version);
|
||||
if (minor_version != boost::none) node.put("minor_version", *minor_version);
|
||||
if (nonce != boost::none) node.put("nonce", *nonce);
|
||||
if (minerTxId != boost::none) node.put("minerTxId", *minerTxId);
|
||||
if (numTxs != boost::none) node.put("numTxs", *numTxs);
|
||||
if (orphanStatus != boost::none) node.put("orphanStatus", *orphanStatus);
|
||||
if (prevId != boost::none) node.put("prevId", *prevId);
|
||||
if (miner_tx_id != boost::none) node.put("miner_tx_id", *miner_tx_id);
|
||||
if (num_txs != boost::none) node.put("num_txs", *num_txs);
|
||||
if (orphan_status != boost::none) node.put("orphan_status", *orphan_status);
|
||||
if (prev_id != boost::none) node.put("prev_id", *prev_id);
|
||||
if (reward != boost::none) node.put("reward", *reward);
|
||||
if (powHash != boost::none) node.put("powHash", *powHash);
|
||||
if (pow_hash != boost::none) node.put("pow_hash", *pow_hash);
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -116,19 +116,19 @@ namespace monero {
|
||||
timestamp = monero_utils::reconcile(timestamp, other->timestamp, boost::none, boost::none, true, "block header timestamp"); // timestamp can increase
|
||||
size = monero_utils::reconcile(size, other->size, "block header size");
|
||||
weight = monero_utils::reconcile(weight, other->weight, "block header weight");
|
||||
longTermWeight = monero_utils::reconcile(longTermWeight, other->longTermWeight, "block header long term weight");
|
||||
long_term_weight = monero_utils::reconcile(long_term_weight, other->long_term_weight, "block header long term weight");
|
||||
depth = monero_utils::reconcile(depth, other->depth, "block header depth");
|
||||
difficulty = monero_utils::reconcile(difficulty, other->difficulty, "difficulty");
|
||||
cumulativeDifficulty = monero_utils::reconcile(cumulativeDifficulty, other->cumulativeDifficulty, "cumulativeDifficulty");
|
||||
majorVersion = monero_utils::reconcile(majorVersion, other->majorVersion, "majorVersion");
|
||||
minorVersion = monero_utils::reconcile(minorVersion, other->minorVersion, "minorVersion");
|
||||
cumulative_difficulty = monero_utils::reconcile(cumulative_difficulty, other->cumulative_difficulty, "cumulative_difficulty");
|
||||
major_version = monero_utils::reconcile(major_version, other->major_version, "major_version");
|
||||
minor_version = monero_utils::reconcile(minor_version, other->minor_version, "minor_version");
|
||||
nonce = monero_utils::reconcile(nonce, other->nonce, "nonce");
|
||||
minerTxId = monero_utils::reconcile(minerTxId, other->minerTxId);
|
||||
numTxs = monero_utils::reconcile(numTxs, other->numTxs, "block header numTxs");
|
||||
orphanStatus = monero_utils::reconcile(orphanStatus, other->orphanStatus);
|
||||
prevId = monero_utils::reconcile(prevId, other->prevId);
|
||||
miner_tx_id = monero_utils::reconcile(miner_tx_id, other->miner_tx_id);
|
||||
num_txs = monero_utils::reconcile(num_txs, other->num_txs, "block header num_txs");
|
||||
orphan_status = monero_utils::reconcile(orphan_status, other->orphan_status);
|
||||
prev_id = monero_utils::reconcile(prev_id, other->prev_id);
|
||||
reward = monero_utils::reconcile(reward, other->reward, "block header reward");
|
||||
powHash = monero_utils::reconcile(powHash, other->powHash);
|
||||
pow_hash = monero_utils::reconcile(pow_hash, other->pow_hash);
|
||||
}
|
||||
|
||||
// ----------------------------- MONERO BLOCK -------------------------------
|
||||
@@ -136,9 +136,9 @@ namespace monero {
|
||||
boost::property_tree::ptree monero_block::to_property_tree() const {
|
||||
boost::property_tree::ptree node = monero_block_header::to_property_tree();
|
||||
if (hex != boost::none) node.put("hex", *hex);
|
||||
if (minerTx != boost::none) node.add_child("minerTx", (*minerTx)->to_property_tree());
|
||||
if (miner_tx != boost::none) node.add_child("miner_tx", (*miner_tx)->to_property_tree());
|
||||
if (!txs.empty()) node.add_child("txs", monero_utils::to_property_tree(txs));
|
||||
if (!txIds.empty()) node.add_child("txIds", monero_utils::to_property_tree(txIds));
|
||||
if (!tx_ids.empty()) node.add_child("tx_ids", monero_utils::to_property_tree(tx_ids));
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -155,13 +155,13 @@ namespace monero {
|
||||
|
||||
// merge reconcilable block extensions
|
||||
hex = monero_utils::reconcile(hex, other->hex);
|
||||
txIds = monero_utils::reconcile(txIds, other->txIds);
|
||||
tx_ids = monero_utils::reconcile(tx_ids, other->tx_ids);
|
||||
|
||||
// merge miner tx
|
||||
if (minerTx == boost::none) minerTx = other->minerTx;
|
||||
if (other->minerTx != boost::none) {
|
||||
other->minerTx.get()->block = self;
|
||||
minerTx.get()->merge(minerTx.get(), other->minerTx.get());
|
||||
if (miner_tx == boost::none) miner_tx = other->miner_tx;
|
||||
if (other->miner_tx != boost::none) {
|
||||
other->miner_tx.get()->block = self;
|
||||
miner_tx.get()->merge(miner_tx.get(), other->miner_tx.get());
|
||||
}
|
||||
|
||||
// merge non-miner txs
|
||||
@@ -179,24 +179,24 @@ namespace monero {
|
||||
MTRACE("monero_tx::copy(const shared_ptr<monero_tx>& src, const shared_ptr<monero_tx>& tgt)");
|
||||
tgt->id = src->id;
|
||||
tgt->version = src->version;
|
||||
tgt->isMinerTx = src->isMinerTx;
|
||||
tgt->paymentId = src->paymentId;
|
||||
tgt->is_miner_tx = src->is_miner_tx;
|
||||
tgt->payment_id = src->payment_id;
|
||||
tgt->fee = src->fee;
|
||||
tgt->mixin = src->mixin;
|
||||
tgt->doNotRelay = src->doNotRelay;
|
||||
tgt->isRelayed = src->isRelayed;
|
||||
tgt->isConfirmed = src->isConfirmed;
|
||||
tgt->inTxPool = src->inTxPool;
|
||||
tgt->numConfirmations = src->numConfirmations;
|
||||
tgt->unlockTime = src->unlockTime;
|
||||
tgt->lastRelayedTimestamp = src->lastRelayedTimestamp;
|
||||
tgt->receivedTimestamp = src->receivedTimestamp;
|
||||
tgt->isDoubleSpendSeen = src->isDoubleSpendSeen;
|
||||
tgt->do_not_relay = src->do_not_relay;
|
||||
tgt->is_relayed = src->is_relayed;
|
||||
tgt->is_confirmed = src->is_confirmed;
|
||||
tgt->in_tx_pool = src->in_tx_pool;
|
||||
tgt->num_confirmations = src->num_confirmations;
|
||||
tgt->unlock_time = src->unlock_time;
|
||||
tgt->last_relayed_timestamp = src->last_relayed_timestamp;
|
||||
tgt->received_timestamp = src->received_timestamp;
|
||||
tgt->is_double_spend_seen = src->is_double_spend_seen;
|
||||
tgt->key = src->key;
|
||||
tgt->fullHex = src->fullHex;
|
||||
tgt->prunedHex = src->prunedHex;
|
||||
tgt->prunableHex = src->prunableHex;
|
||||
tgt->prunableHash = src->prunableHash;
|
||||
tgt->full_hex = src->full_hex;
|
||||
tgt->pruned_hex = src->pruned_hex;
|
||||
tgt->prunable_hex = src->prunable_hex;
|
||||
tgt->prunable_hash = src->prunable_hash;
|
||||
tgt->size = src->size;
|
||||
tgt->weight = src->weight;
|
||||
if (!src->vins.empty()) {
|
||||
@@ -215,18 +215,18 @@ namespace monero {
|
||||
tgt->vouts.push_back(voutCopy);
|
||||
}
|
||||
}
|
||||
if (!src->outputIndices.empty()) tgt->outputIndices = vector<uint32_t>(src->outputIndices);
|
||||
if (!src->m_output_indices.empty()) tgt->m_output_indices = vector<uint32_t>(src->m_output_indices);
|
||||
tgt->metadata = src->metadata;
|
||||
tgt->commonTxSets = src->commonTxSets;
|
||||
tgt->common_tx_sets = src->common_tx_sets;
|
||||
if (!src->extra.empty()) throw runtime_error("extra deep copy not implemented"); // TODO: implement extra
|
||||
tgt->rctSignatures = src->rctSignatures;
|
||||
tgt->rctSigPrunable = src->rctSigPrunable;
|
||||
tgt->isKeptByBlock = src->isKeptByBlock;
|
||||
tgt->isFailed = src->isFailed;
|
||||
tgt->lastFailedHeight = src->lastFailedHeight;
|
||||
tgt->lastFailedId = src->lastFailedId;
|
||||
tgt->maxUsedBlockHeight = src->maxUsedBlockHeight;
|
||||
tgt->maxUsedBlockId = src->maxUsedBlockId;
|
||||
tgt->rct_signatures = src->rct_signatures;
|
||||
tgt->rct_sig_prunable = src->rct_sig_prunable;
|
||||
tgt->is_kept_by_block = src->is_kept_by_block;
|
||||
tgt->is_failed = src->is_failed;
|
||||
tgt->last_failed_height = src->last_failed_height;
|
||||
tgt->last_failed_id = src->last_failed_id;
|
||||
tgt->max_used_block_height = src->max_used_block_height;
|
||||
tgt->max_used_block_id = src->max_used_block_id;
|
||||
if (!src->signatures.empty()) tgt->signatures = vector<string>(src->signatures);
|
||||
return tgt;
|
||||
}
|
||||
@@ -235,40 +235,40 @@ namespace monero {
|
||||
boost::property_tree::ptree node;
|
||||
if (id != boost::none) node.put("id", *id);
|
||||
if (version != boost::none) node.put("version", *version);
|
||||
if (isMinerTx != boost::none) node.put("isMinerTx", *isMinerTx);
|
||||
if (paymentId != boost::none) node.put("paymentId", *paymentId);
|
||||
if (is_miner_tx != boost::none) node.put("is_miner_tx", *is_miner_tx);
|
||||
if (payment_id != boost::none) node.put("payment_id", *payment_id);
|
||||
if (fee != boost::none) node.put("fee", *fee);
|
||||
if (mixin != boost::none) node.put("mixin", *mixin);
|
||||
if (doNotRelay != boost::none) node.put("doNotRelay", *doNotRelay);
|
||||
if (isRelayed != boost::none) node.put("isRelayed", *isRelayed);
|
||||
if (isConfirmed != boost::none) node.put("isConfirmed", *isConfirmed);
|
||||
if (inTxPool != boost::none) node.put("inTxPool", *inTxPool);
|
||||
if (numConfirmations != boost::none) node.put("numConfirmations", *numConfirmations);
|
||||
if (unlockTime != boost::none) node.put("unlockTime", *unlockTime);
|
||||
if (lastRelayedTimestamp != boost::none) node.put("lastRelayedTimestamp", *lastRelayedTimestamp);
|
||||
if (receivedTimestamp != boost::none) node.put("receivedTimestamp", *receivedTimestamp);
|
||||
if (isDoubleSpendSeen != boost::none) node.put("isDoubleSpendSeen", *isDoubleSpendSeen);
|
||||
if (do_not_relay != boost::none) node.put("do_not_relay", *do_not_relay);
|
||||
if (is_relayed != boost::none) node.put("is_relayed", *is_relayed);
|
||||
if (is_confirmed != boost::none) node.put("is_confirmed", *is_confirmed);
|
||||
if (in_tx_pool != boost::none) node.put("in_tx_pool", *in_tx_pool);
|
||||
if (num_confirmations != boost::none) node.put("num_confirmations", *num_confirmations);
|
||||
if (unlock_time != boost::none) node.put("unlock_time", *unlock_time);
|
||||
if (last_relayed_timestamp != boost::none) node.put("last_relayed_timestamp", *last_relayed_timestamp);
|
||||
if (received_timestamp != boost::none) node.put("received_timestamp", *received_timestamp);
|
||||
if (is_double_spend_seen != boost::none) node.put("is_double_spend_seen", *is_double_spend_seen);
|
||||
if (key != boost::none) node.put("key", *key);
|
||||
if (fullHex != boost::none) node.put("fullHex", *fullHex);
|
||||
if (prunedHex != boost::none) node.put("prunedHex", *prunedHex);
|
||||
if (prunableHex != boost::none) node.put("prunableHex", *prunableHex);
|
||||
if (prunableHash != boost::none) node.put("prunableHash", *prunableHash);
|
||||
if (full_hex != boost::none) node.put("full_hex", *full_hex);
|
||||
if (pruned_hex != boost::none) node.put("pruned_hex", *pruned_hex);
|
||||
if (prunable_hex != boost::none) node.put("prunable_hex", *prunable_hex);
|
||||
if (prunable_hash != boost::none) node.put("prunable_hash", *prunable_hash);
|
||||
if (size != boost::none) node.put("size", *size);
|
||||
if (weight != boost::none) node.put("weight", *weight);
|
||||
if (!vins.empty()) node.add_child("vins", monero_utils::to_property_tree(vins));
|
||||
if (!vouts.empty()) node.add_child("vouts", monero_utils::to_property_tree(vouts));
|
||||
if (!outputIndices.empty()) throw runtime_error("outputIndices not implemented");
|
||||
if (!m_output_indices.empty()) throw runtime_error("m_output_indices not implemented");
|
||||
if (metadata != boost::none) node.put("metadata", *metadata);
|
||||
if (commonTxSets != boost::none) throw runtime_error("commonTxSets not implemented");
|
||||
if (common_tx_sets != boost::none) throw runtime_error("common_tx_sets not implemented");
|
||||
if (!extra.empty()) node.add_child("extra", monero_utils::to_property_tree(extra));
|
||||
if (rctSignatures != boost::none) throw runtime_error("rctSignatures not implemented");
|
||||
if (rctSigPrunable != boost::none) throw runtime_error("rctSigPrunable not implemented");
|
||||
if (isKeptByBlock != boost::none) node.put("isKeptByBlock", *isKeptByBlock);
|
||||
if (isFailed != boost::none) node.put("isFailed", *isFailed);
|
||||
if (lastFailedHeight != boost::none) node.put("lastFailedHeight", *lastFailedHeight);
|
||||
if (lastFailedId != boost::none) node.put("lastFailedId", *lastFailedId);
|
||||
if (maxUsedBlockHeight != boost::none) node.put("maxUsedBlockHeight", *maxUsedBlockHeight);
|
||||
if (maxUsedBlockId != boost::none) node.put("maxUsedBlockId", *maxUsedBlockId);
|
||||
if (rct_signatures != boost::none) throw runtime_error("rct_signatures not implemented");
|
||||
if (rct_sig_prunable != boost::none) throw runtime_error("rct_sig_prunable not implemented");
|
||||
if (is_kept_by_block != boost::none) node.put("is_kept_by_block", *is_kept_by_block);
|
||||
if (is_failed != boost::none) node.put("is_failed", *is_failed);
|
||||
if (last_failed_height != boost::none) node.put("last_failed_height", *last_failed_height);
|
||||
if (last_failed_id != boost::none) node.put("last_failed_id", *last_failed_id);
|
||||
if (max_used_block_height != boost::none) node.put("max_used_block_height", *max_used_block_height);
|
||||
if (max_used_block_id != boost::none) node.put("max_used_block_id", *max_used_block_id);
|
||||
if (!signatures.empty()) throw runtime_error("signatures not implemented");
|
||||
return node;
|
||||
}
|
||||
@@ -301,35 +301,35 @@ namespace monero {
|
||||
// otherwise merge tx fields
|
||||
id = monero_utils::reconcile(id, other->id);
|
||||
version = monero_utils::reconcile(version, other->version);
|
||||
paymentId = monero_utils::reconcile(paymentId, other->paymentId);
|
||||
payment_id = monero_utils::reconcile(payment_id, other->payment_id);
|
||||
fee = monero_utils::reconcile(fee, other->fee, "tx fee");
|
||||
mixin = monero_utils::reconcile(mixin, other->mixin, "tx mixin");
|
||||
isConfirmed = monero_utils::reconcile(isConfirmed, other->isConfirmed);
|
||||
doNotRelay = monero_utils::reconcile(doNotRelay, other->doNotRelay);
|
||||
isRelayed = monero_utils::reconcile(isRelayed, other->isRelayed);
|
||||
isDoubleSpendSeen = monero_utils::reconcile(isDoubleSpendSeen, other->isDoubleSpendSeen);
|
||||
is_confirmed = monero_utils::reconcile(is_confirmed, other->is_confirmed);
|
||||
do_not_relay = monero_utils::reconcile(do_not_relay, other->do_not_relay);
|
||||
is_relayed = monero_utils::reconcile(is_relayed, other->is_relayed);
|
||||
is_double_spend_seen = monero_utils::reconcile(is_double_spend_seen, other->is_double_spend_seen);
|
||||
key = monero_utils::reconcile(key, other->key);
|
||||
fullHex = monero_utils::reconcile(fullHex, other->fullHex);
|
||||
prunedHex = monero_utils::reconcile(prunedHex, other->prunedHex);
|
||||
prunableHex = monero_utils::reconcile(prunableHex, other->prunableHex);
|
||||
prunableHash = monero_utils::reconcile(prunableHash, other->prunableHash);
|
||||
full_hex = monero_utils::reconcile(full_hex, other->full_hex);
|
||||
pruned_hex = monero_utils::reconcile(pruned_hex, other->pruned_hex);
|
||||
prunable_hex = monero_utils::reconcile(prunable_hex, other->prunable_hex);
|
||||
prunable_hash = monero_utils::reconcile(prunable_hash, other->prunable_hash);
|
||||
size = monero_utils::reconcile(size, other->size, "tx size");
|
||||
weight = monero_utils::reconcile(weight, other->weight, "tx weight");
|
||||
//outputIndices = monero_utils::reconcile(outputIndices, other->outputIndices); // TODO
|
||||
//m_output_indices = monero_utils::reconcile(m_output_indices, other->m_output_indices); // TODO
|
||||
metadata = monero_utils::reconcile(metadata, other->metadata);
|
||||
commonTxSets = monero_utils::reconcile(commonTxSets, other->commonTxSets);
|
||||
common_tx_sets = monero_utils::reconcile(common_tx_sets, other->common_tx_sets);
|
||||
//extra = monero_utils::reconcile(extra, other->extra); // TODO
|
||||
rctSignatures = monero_utils::reconcile(rctSignatures, other->rctSignatures);
|
||||
rctSigPrunable = monero_utils::reconcile(rctSigPrunable, other->rctSigPrunable);
|
||||
isKeptByBlock = monero_utils::reconcile(isKeptByBlock, other->isKeptByBlock);
|
||||
isFailed = monero_utils::reconcile(isFailed, other->isFailed);
|
||||
lastFailedHeight = monero_utils::reconcile(lastFailedHeight, other->lastFailedHeight, "lastFailedHeight");
|
||||
lastFailedId = monero_utils::reconcile(lastFailedId, other->lastFailedId);
|
||||
maxUsedBlockHeight = monero_utils::reconcile(maxUsedBlockHeight, other->maxUsedBlockHeight, "maxUsedBlockHeight");
|
||||
maxUsedBlockId = monero_utils::reconcile(maxUsedBlockId, other->maxUsedBlockId);
|
||||
rct_signatures = monero_utils::reconcile(rct_signatures, other->rct_signatures);
|
||||
rct_sig_prunable = monero_utils::reconcile(rct_sig_prunable, other->rct_sig_prunable);
|
||||
is_kept_by_block = monero_utils::reconcile(is_kept_by_block, other->is_kept_by_block);
|
||||
is_failed = monero_utils::reconcile(is_failed, other->is_failed);
|
||||
last_failed_height = monero_utils::reconcile(last_failed_height, other->last_failed_height, "last_failed_height");
|
||||
last_failed_id = monero_utils::reconcile(last_failed_id, other->last_failed_id);
|
||||
max_used_block_height = monero_utils::reconcile(max_used_block_height, other->max_used_block_height, "max_used_block_height");
|
||||
max_used_block_id = monero_utils::reconcile(max_used_block_id, other->max_used_block_id);
|
||||
//signatures = monero_utils::reconcile(signatures, other->signatures); // TODO
|
||||
unlockTime = monero_utils::reconcile(unlockTime, other->unlockTime, "unlockTime");
|
||||
numConfirmations = monero_utils::reconcile(numConfirmations, other->numConfirmations, "numConfirmations");
|
||||
unlock_time = monero_utils::reconcile(unlock_time, other->unlock_time, "unlock_time");
|
||||
num_confirmations = monero_utils::reconcile(num_confirmations, other->num_confirmations, "num_confirmations");
|
||||
|
||||
// merge vins
|
||||
if (!other->vins.empty()) {
|
||||
@@ -337,7 +337,7 @@ namespace monero {
|
||||
bool merged = false;
|
||||
merger->tx = self;
|
||||
for (const shared_ptr<monero_output>& mergee : vins) {
|
||||
if ((*mergee->keyImage)->hex == (*merger->keyImage)->hex) {
|
||||
if ((*mergee->key_image)->hex == (*merger->key_image)->hex) {
|
||||
mergee->merge(mergee, merger);
|
||||
merged = true;
|
||||
break;
|
||||
@@ -356,14 +356,14 @@ namespace monero {
|
||||
// determine if key images present
|
||||
int numKeyImages = 0;
|
||||
for (const shared_ptr<monero_output> vout : vouts) {
|
||||
if (vout->keyImage != boost::none) {
|
||||
if ((*vout->keyImage)->hex == boost::none) throw runtime_error("Key image hex cannot be null");
|
||||
if (vout->key_image != boost::none) {
|
||||
if ((*vout->key_image)->hex == boost::none) throw runtime_error("Key image hex cannot be null");
|
||||
numKeyImages++;
|
||||
}
|
||||
}
|
||||
for (const shared_ptr<monero_output>& vout : other->vouts) {
|
||||
if (vout->keyImage != boost::none) {
|
||||
if ((*vout->keyImage)->hex == boost::none) throw runtime_error("Key image hex cannot be null");
|
||||
if (vout->key_image != boost::none) {
|
||||
if ((*vout->key_image)->hex == boost::none) throw runtime_error("Key image hex cannot be null");
|
||||
numKeyImages++;
|
||||
}
|
||||
}
|
||||
@@ -375,7 +375,7 @@ namespace monero {
|
||||
bool merged = false;
|
||||
merger->tx = self;
|
||||
for (const shared_ptr<monero_output>& mergee : vouts) {
|
||||
if ((*mergee->keyImage)->hex == (*merger->keyImage)->hex) {
|
||||
if ((*mergee->key_image)->hex == (*merger->key_image)->hex) {
|
||||
mergee->merge(mergee, merger);
|
||||
merged = true;
|
||||
break;
|
||||
@@ -396,14 +396,14 @@ namespace monero {
|
||||
}
|
||||
|
||||
// handle unrelayed -> relayed -> confirmed
|
||||
if (*isConfirmed) {
|
||||
inTxPool = false;
|
||||
receivedTimestamp = boost::none;
|
||||
lastRelayedTimestamp = boost::none;
|
||||
if (*is_confirmed) {
|
||||
in_tx_pool = false;
|
||||
received_timestamp = boost::none;
|
||||
last_relayed_timestamp = boost::none;
|
||||
} else {
|
||||
inTxPool = monero_utils::reconcile(inTxPool, other->inTxPool, boost::none, true, boost::none); // unrelayed -> tx pool
|
||||
receivedTimestamp = monero_utils::reconcile(receivedTimestamp, other->receivedTimestamp, boost::none, boost::none, false, "receivedTimestamp"); // take earliest receive time
|
||||
lastRelayedTimestamp = monero_utils::reconcile(lastRelayedTimestamp, other->lastRelayedTimestamp, boost::none, boost::none, true, "lastRelayedTimestamp"); // take latest relay time
|
||||
in_tx_pool = monero_utils::reconcile(in_tx_pool, other->in_tx_pool, boost::none, true, boost::none); // unrelayed -> tx pool
|
||||
received_timestamp = monero_utils::reconcile(received_timestamp, other->received_timestamp, boost::none, boost::none, false, "received_timestamp"); // take earliest receive time
|
||||
last_relayed_timestamp = monero_utils::reconcile(last_relayed_timestamp, other->last_relayed_timestamp, boost::none, boost::none, true, "last_relayed_timestamp"); // take latest relay time
|
||||
}
|
||||
}
|
||||
|
||||
@@ -432,21 +432,21 @@ namespace monero {
|
||||
shared_ptr<monero_output> monero_output::copy(const shared_ptr<monero_output>& src, const shared_ptr<monero_output>& tgt) const {
|
||||
if (this != src.get()) throw runtime_error("this != src");
|
||||
tgt->tx = src->tx; // reference same parent tx by default
|
||||
if (src->keyImage != boost::none) tgt->keyImage = src->keyImage.get()->copy(src->keyImage.get(), make_shared<monero_key_image>());
|
||||
if (src->key_image != boost::none) tgt->key_image = src->key_image.get()->copy(src->key_image.get(), make_shared<monero_key_image>());
|
||||
tgt->amount = src->amount;
|
||||
tgt->index = src->index;
|
||||
if (!src->ringOutputIndices.empty()) tgt->ringOutputIndices = vector<uint64_t>(src->ringOutputIndices);
|
||||
tgt->stealthPublicKey = src->stealthPublicKey;
|
||||
if (!src->ring_output_indices.empty()) tgt->ring_output_indices = vector<uint64_t>(src->ring_output_indices);
|
||||
tgt->stealth_public_key = src->stealth_public_key;
|
||||
return tgt;
|
||||
}
|
||||
|
||||
boost::property_tree::ptree monero_output::to_property_tree() const {
|
||||
boost::property_tree::ptree node;
|
||||
if (keyImage != boost::none) node.add_child("keyImage", (*keyImage)->to_property_tree());
|
||||
if (key_image != boost::none) node.add_child("key_image", (*key_image)->to_property_tree());
|
||||
if (amount != boost::none) node.put("amount", *amount);
|
||||
if (index != boost::none) node.put("index", *index);
|
||||
if (!ringOutputIndices.empty()) node.add_child("ringOutputIndices", monero_utils::to_property_tree(ringOutputIndices));
|
||||
if (stealthPublicKey != boost::none) node.put("stealthPublicKey", *stealthPublicKey);
|
||||
if (!ring_output_indices.empty()) node.add_child("ring_output_indices", monero_utils::to_property_tree(ring_output_indices));
|
||||
if (stealth_public_key != boost::none) node.put("stealth_public_key", *stealth_public_key);
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -461,8 +461,8 @@ namespace monero {
|
||||
}
|
||||
|
||||
// otherwise merge output fields
|
||||
if (keyImage == boost::none) keyImage = other->keyImage;
|
||||
else if (other->keyImage != boost::none) keyImage.get()->merge(keyImage.get(), other->keyImage.get());
|
||||
if (key_image == boost::none) key_image = other->key_image;
|
||||
else if (other->key_image != boost::none) key_image.get()->merge(key_image.get(), other->key_image.get());
|
||||
amount = monero_utils::reconcile(amount, other->amount, "output amount");
|
||||
index = monero_utils::reconcile(index, other->index, "output index");
|
||||
}
|
||||
|
||||
@@ -97,9 +97,9 @@ namespace monero {
|
||||
* TODO: switch to boost::optional<string>
|
||||
*/
|
||||
struct monero_rpc_connection {
|
||||
string uri;
|
||||
boost::optional<string> username;
|
||||
boost::optional<string> password;
|
||||
string m_uri;
|
||||
boost::optional<string> m_username;
|
||||
boost::optional<string> m_password;
|
||||
monero_rpc_connection(const string& uri = "", const boost::optional<string>& username = boost::none, const boost::optional<string>& password = boost::none) : uri(uri), username(username), password(password) {}
|
||||
};
|
||||
|
||||
@@ -113,24 +113,24 @@ namespace monero {
|
||||
* TODO: a header that is transmitted may have fewer fields like cryptonote::block_header; separate?
|
||||
*/
|
||||
struct monero_block_header : public serializable_struct {
|
||||
boost::optional<string> id;
|
||||
boost::optional<uint64_t> height;
|
||||
boost::optional<uint64_t> timestamp;
|
||||
boost::optional<uint64_t> size;
|
||||
boost::optional<uint64_t> weight;
|
||||
boost::optional<uint64_t> longTermWeight;
|
||||
boost::optional<string> m_id;
|
||||
boost::optional<uint64_t> m_height;
|
||||
boost::optional<uint64_t> m_timestamp;
|
||||
boost::optional<uint64_t> m_size;
|
||||
boost::optional<uint64_t> m_weight;
|
||||
boost::optional<uint64_t> long_term_weight;
|
||||
boost::optional<uint64_t> depth;
|
||||
boost::optional<uint64_t> difficulty;
|
||||
boost::optional<uint64_t> cumulativeDifficulty;
|
||||
boost::optional<uint32_t> majorVersion;
|
||||
boost::optional<uint32_t> minorVersion;
|
||||
boost::optional<uint64_t> cumulative_difficulty;
|
||||
boost::optional<uint32_t> major_version;
|
||||
boost::optional<uint32_t> minor_version;
|
||||
boost::optional<uint64_t> nonce;
|
||||
boost::optional<string> minerTxId;
|
||||
boost::optional<uint32_t> numTxs;
|
||||
boost::optional<bool> orphanStatus;
|
||||
boost::optional<string> prevId;
|
||||
boost::optional<string> miner_tx_id;
|
||||
boost::optional<uint32_t> num_txs;
|
||||
boost::optional<bool> orphan_status;
|
||||
boost::optional<string> prev_id;
|
||||
boost::optional<uint64_t> reward;
|
||||
boost::optional<string> powHash;
|
||||
boost::optional<string> pow_hash;
|
||||
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
virtual void merge(const shared_ptr<monero_block_header>& self, const shared_ptr<monero_block_header>& other);
|
||||
@@ -141,9 +141,9 @@ namespace monero {
|
||||
*/
|
||||
struct monero_block : public monero_block_header {
|
||||
boost::optional<string> hex;
|
||||
boost::optional<shared_ptr<monero_tx>> minerTx;
|
||||
boost::optional<shared_ptr<monero_tx>> miner_tx;
|
||||
vector<shared_ptr<monero_tx>> txs;
|
||||
vector<string> txIds;
|
||||
vector<string> tx_ids;
|
||||
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
void merge(const shared_ptr<monero_block_header>& self, const shared_ptr<monero_block_header>& other);
|
||||
@@ -158,40 +158,40 @@ namespace monero {
|
||||
boost::optional<shared_ptr<monero_block>> block;
|
||||
boost::optional<string> id;
|
||||
boost::optional<uint32_t> version;
|
||||
boost::optional<bool> isMinerTx;
|
||||
boost::optional<string> paymentId;
|
||||
boost::optional<bool> is_miner_tx;
|
||||
boost::optional<string> payment_id;
|
||||
boost::optional<uint64_t> fee;
|
||||
boost::optional<uint32_t> mixin;
|
||||
boost::optional<bool> doNotRelay;
|
||||
boost::optional<bool> isRelayed;
|
||||
boost::optional<bool> isConfirmed;
|
||||
boost::optional<bool> inTxPool;
|
||||
boost::optional<uint64_t> numConfirmations;
|
||||
boost::optional<uint64_t> unlockTime;
|
||||
boost::optional<uint64_t> lastRelayedTimestamp;
|
||||
boost::optional<uint64_t> receivedTimestamp;
|
||||
boost::optional<bool> isDoubleSpendSeen;
|
||||
boost::optional<bool> do_not_relay;
|
||||
boost::optional<bool> is_relayed;
|
||||
boost::optional<bool> is_confirmed;
|
||||
boost::optional<bool> in_tx_pool;
|
||||
boost::optional<uint64_t> num_confirmations;
|
||||
boost::optional<uint64_t> unlock_time;
|
||||
boost::optional<uint64_t> last_relayed_timestamp;
|
||||
boost::optional<uint64_t> received_timestamp;
|
||||
boost::optional<bool> is_double_spend_seen;
|
||||
boost::optional<string> key;
|
||||
boost::optional<string> fullHex;
|
||||
boost::optional<string> prunedHex;
|
||||
boost::optional<string> prunableHex;
|
||||
boost::optional<string> prunableHash;
|
||||
boost::optional<string> full_hex;
|
||||
boost::optional<string> pruned_hex;
|
||||
boost::optional<string> prunable_hex;
|
||||
boost::optional<string> prunable_hash;
|
||||
boost::optional<uint32_t> size;
|
||||
boost::optional<uint32_t> weight;
|
||||
vector<shared_ptr<monero_output>> vins;
|
||||
vector<shared_ptr<monero_output>> vouts;
|
||||
vector<uint32_t> outputIndices;
|
||||
vector<uint32_t> m_output_indices;
|
||||
boost::optional<string> metadata;
|
||||
boost::optional<string> commonTxSets;
|
||||
boost::optional<string> common_tx_sets;
|
||||
vector<uint8_t> extra;
|
||||
boost::optional<string> rctSignatures; // TODO: implement
|
||||
boost::optional<string> rctSigPrunable; // TODO: implement
|
||||
boost::optional<bool> isKeptByBlock;
|
||||
boost::optional<bool> isFailed;
|
||||
boost::optional<uint32_t> lastFailedHeight;
|
||||
boost::optional<string> lastFailedId;
|
||||
boost::optional<uint32_t> maxUsedBlockHeight;
|
||||
boost::optional<string> maxUsedBlockId;
|
||||
boost::optional<string> rct_signatures; // TODO: implement
|
||||
boost::optional<string> rct_sig_prunable; // TODO: implement
|
||||
boost::optional<bool> is_kept_by_block;
|
||||
boost::optional<bool> is_failed;
|
||||
boost::optional<uint32_t> last_failed_height;
|
||||
boost::optional<string> last_failed_id;
|
||||
boost::optional<uint32_t> max_used_block_height;
|
||||
boost::optional<string> max_used_block_id;
|
||||
vector<string> signatures;
|
||||
|
||||
shared_ptr<monero_tx> copy(const shared_ptr<monero_tx>& src, const shared_ptr<monero_tx>& tgt) const;
|
||||
@@ -217,11 +217,11 @@ namespace monero {
|
||||
*/
|
||||
struct monero_output : public serializable_struct {
|
||||
shared_ptr<monero_tx> tx;
|
||||
boost::optional<shared_ptr<monero_key_image>> keyImage;
|
||||
boost::optional<shared_ptr<monero_key_image>> key_image;
|
||||
boost::optional<uint64_t> amount;
|
||||
boost::optional<uint64_t> index;
|
||||
vector<uint64_t> ringOutputIndices;
|
||||
boost::optional<string> stealthPublicKey;
|
||||
vector<uint64_t> ring_output_indices;
|
||||
boost::optional<string> stealth_public_key;
|
||||
|
||||
shared_ptr<monero_output> copy(const shared_ptr<monero_output>& src, const shared_ptr<monero_output>& tgt) const;
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
|
||||
+147
-147
@@ -61,139 +61,139 @@ using namespace monero_utils;
|
||||
|
||||
// ------------------------------- INNER HELPERS ------------------------------
|
||||
|
||||
void nodeToTransfer(const boost::property_tree::ptree& node, shared_ptr<monero_transfer> transfer) {
|
||||
void node_to_transfer(const boost::property_tree::ptree& node, shared_ptr<monero_transfer> transfer) {
|
||||
|
||||
// initialize transfer from node
|
||||
for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) {
|
||||
string key = it->first;
|
||||
if (key == string("accountIndex")) transfer->accountIndex = it->second.get_value<uint32_t>();
|
||||
if (key == string("account_index")) transfer->account_index = it->second.get_value<uint32_t>();
|
||||
}
|
||||
}
|
||||
|
||||
shared_ptr<monero_transfer_request> nodeToTransferRequest(const boost::property_tree::ptree& node) {
|
||||
shared_ptr<monero_transfer_request> transferRequest = make_shared<monero_transfer_request>();
|
||||
nodeToTransfer(node, transferRequest);
|
||||
shared_ptr<monero_transfer_request> node_to_transfer_request(const boost::property_tree::ptree& node) {
|
||||
shared_ptr<monero_transfer_request> transfer_request = make_shared<monero_transfer_request>();
|
||||
node_to_transfer(node, transfer_request);
|
||||
|
||||
// initialize request from node
|
||||
for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) {
|
||||
string key = it->first;
|
||||
if (key == string("isIncoming")) transferRequest->isIncoming = it->second.get_value<bool>();
|
||||
else if (key == string("address")) transferRequest->address = it->second.data();
|
||||
if (key == string("is_incoming")) transfer_request->is_incoming = it->second.get_value<bool>();
|
||||
else if (key == string("address")) transfer_request->address = it->second.data();
|
||||
else if (key == string("addresses")) throw runtime_error("addresses not implemented");
|
||||
else if (key == string("subaddressIndex")) transferRequest->subaddressIndex = it->second.get_value<uint32_t>();
|
||||
else if (key == string("subaddressIndices")) {
|
||||
vector<uint32_t> subaddressIndices;
|
||||
for (const auto& child : it->second) subaddressIndices.push_back(child.second.get_value<uint32_t>());
|
||||
transferRequest->subaddressIndices = subaddressIndices;
|
||||
else if (key == string("subaddress_index")) transfer_request->subaddress_index = it->second.get_value<uint32_t>();
|
||||
else if (key == string("subaddress_indices")) {
|
||||
vector<uint32_t> subaddress_indices;
|
||||
for (const auto& child : it->second) subaddress_indices.push_back(child.second.get_value<uint32_t>());
|
||||
transfer_request->subaddress_indices = subaddress_indices;
|
||||
}
|
||||
else if (key == string("destinations")) throw runtime_error("destinations not implemented");
|
||||
else if (key == string("hasDestinations")) transferRequest->hasDestinations = it->second.get_value<bool>();
|
||||
else if (key == string("txRequest")) throw runtime_error("txRequest not implemented");
|
||||
else if (key == string("has_destinations")) transfer_request->has_destinations = it->second.get_value<bool>();
|
||||
else if (key == string("tx_request")) throw runtime_error("tx_request not implemented");
|
||||
}
|
||||
|
||||
return transferRequest;
|
||||
return transfer_request;
|
||||
}
|
||||
|
||||
shared_ptr<monero_key_image> nodeToKeyImage(const boost::property_tree::ptree& node) {
|
||||
shared_ptr<monero_key_image> node_to_key_image(const boost::property_tree::ptree& node) {
|
||||
|
||||
// initialize key image from node
|
||||
shared_ptr<monero_key_image> keyImage = make_shared<monero_key_image>();
|
||||
shared_ptr<monero_key_image> key_image = make_shared<monero_key_image>();
|
||||
for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) {
|
||||
string key = it->first;
|
||||
if (key == string("hex")) keyImage->hex = it->second.data();
|
||||
else if (key == string("signature")) keyImage->signature = it->second.data();
|
||||
if (key == string("hex")) key_image->hex = it->second.data();
|
||||
else if (key == string("signature")) key_image->signature = it->second.data();
|
||||
}
|
||||
|
||||
return keyImage;
|
||||
return key_image;
|
||||
}
|
||||
|
||||
void nodeToOutput(const boost::property_tree::ptree& node, shared_ptr<monero_output> output) {
|
||||
void node_to_output(const boost::property_tree::ptree& node, shared_ptr<monero_output> output) {
|
||||
|
||||
// initialize output from node
|
||||
for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) {
|
||||
string key = it->first;
|
||||
if (key == string("keyImage")) output->keyImage = nodeToKeyImage(it->second);
|
||||
if (key == string("key_image")) output->key_image = node_to_key_image(it->second);
|
||||
else if (key == string("amount")) output->amount = it->second.get_value<uint64_t>();
|
||||
else if (key == string("index")) output->index = it->second.get_value<uint32_t>();
|
||||
else if (key == string("ringOutputIndices")) throw runtime_error("nodeToTx() deserialize ringOutputIndices not implemented");
|
||||
else if (key == string("stealthPublicKey")) throw runtime_error("nodeToTx() deserialize stealthPublicKey not implemented");
|
||||
else if (key == string("ring_output_indices")) throw runtime_error("node_to_tx() deserialize ring_output_indices not implemented");
|
||||
else if (key == string("stealth_public_key")) throw runtime_error("node_to_tx() deserialize stealth_public_key not implemented");
|
||||
}
|
||||
}
|
||||
|
||||
void nodeToOutputWallet(const boost::property_tree::ptree& node, shared_ptr<monero_output_wallet> outputWallet) {
|
||||
nodeToOutput(node, outputWallet);
|
||||
void node_to_output_wallet(const boost::property_tree::ptree& node, shared_ptr<monero_output_wallet> output_wallet) {
|
||||
node_to_output(node, output_wallet);
|
||||
for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) {
|
||||
string key = it->first;
|
||||
if (key == string("accountIndex")) outputWallet->accountIndex = it->second.get_value<uint32_t>();
|
||||
else if (key == string("subaddressIndex")) outputWallet->subaddressIndex = it->second.get_value<uint32_t>();
|
||||
else if (key == string("isSpent")) outputWallet->isSpent = it->second.get_value<bool>();
|
||||
else if (key == string("isUnlocked")) outputWallet->isUnlocked = it->second.get_value<bool>();
|
||||
else if (key == string("isFrozen")) outputWallet->isFrozen = it->second.get_value<bool>();
|
||||
if (key == string("account_index")) output_wallet->account_index = it->second.get_value<uint32_t>();
|
||||
else if (key == string("subaddress_index")) output_wallet->subaddress_index = it->second.get_value<uint32_t>();
|
||||
else if (key == string("is_spent")) output_wallet->is_spent = it->second.get_value<bool>();
|
||||
else if (key == string("is_unlocked")) output_wallet->is_unlocked = it->second.get_value<bool>();
|
||||
else if (key == string("is_frozen")) output_wallet->is_frozen = it->second.get_value<bool>();
|
||||
}
|
||||
}
|
||||
|
||||
shared_ptr<monero_output_request> nodeToOutputRequest(const boost::property_tree::ptree& node) {
|
||||
shared_ptr<monero_output_request> outputRequest = make_shared<monero_output_request>();
|
||||
nodeToOutputWallet(node, outputRequest);
|
||||
shared_ptr<monero_output_request> node_to_output_request(const boost::property_tree::ptree& node) {
|
||||
shared_ptr<monero_output_request> output_request = make_shared<monero_output_request>();
|
||||
node_to_output_wallet(node, output_request);
|
||||
|
||||
// initialize request from node
|
||||
for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) {
|
||||
string key = it->first;
|
||||
if (key == string("subaddressIndices")) for (boost::property_tree::ptree::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) outputRequest->subaddressIndices.push_back(it2->second.get_value<uint32_t>());
|
||||
else if (key == string("txRequest")) {} // ignored
|
||||
if (key == string("subaddress_indices")) for (boost::property_tree::ptree::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) output_request->subaddress_indices.push_back(it2->second.get_value<uint32_t>());
|
||||
else if (key == string("tx_request")) {} // ignored
|
||||
}
|
||||
|
||||
return outputRequest;
|
||||
return output_request;
|
||||
}
|
||||
|
||||
void nodeToTx(const boost::property_tree::ptree& node, shared_ptr<monero_tx> tx) {
|
||||
void node_to_tx(const boost::property_tree::ptree& node, shared_ptr<monero_tx> tx) {
|
||||
|
||||
// initialize tx from node
|
||||
for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) {
|
||||
string key = it->first;
|
||||
if (key == string("id")) tx->id = it->second.data();
|
||||
else if (key == string("version")) throw runtime_error("version deserializationn not implemented");
|
||||
else if (key == string("isMinerTx")) tx->isMinerTx = it->second.get_value<bool>();
|
||||
else if (key == string("paymentId")) throw runtime_error("paymentId deserializationn not implemented");
|
||||
else if (key == string("is_miner_tx")) tx->is_miner_tx = it->second.get_value<bool>();
|
||||
else if (key == string("payment_id")) throw runtime_error("payment_id deserializationn not implemented");
|
||||
else if (key == string("fee")) throw runtime_error("fee deserialization not implemented");
|
||||
else if (key == string("mixin")) throw runtime_error("mixin deserialization not implemented");
|
||||
else if (key == string("doNotRelay")) tx->doNotRelay = it->second.get_value<bool>();
|
||||
else if (key == string("isRelayed")) tx->isRelayed = it->second.get_value<bool>();
|
||||
else if (key == string("isConfirmed")) tx->isConfirmed = it->second.get_value<bool>();
|
||||
else if (key == string("inTxPool")) tx->inTxPool = it->second.get_value<bool>();
|
||||
else if (key == string("numConfirmations")) throw runtime_error("numConfirmations deserialization not implemented");
|
||||
else if (key == string("unlockTime")) throw runtime_error("unlockTime deserialization not implemented");
|
||||
else if (key == string("lastRelayedTimestamp")) throw runtime_error("lastRelayedTimestamp deserialization not implemented");
|
||||
else if (key == string("receivedTimestamp")) throw runtime_error("receivedTimestamp deserializationn not implemented");
|
||||
else if (key == string("isDoubleSpendSeen")) tx->isDoubleSpendSeen = it->second.get_value<bool>();
|
||||
else if (key == string("do_not_relay")) tx->do_not_relay = it->second.get_value<bool>();
|
||||
else if (key == string("is_relayed")) tx->is_relayed = it->second.get_value<bool>();
|
||||
else if (key == string("is_confirmed")) tx->is_confirmed = it->second.get_value<bool>();
|
||||
else if (key == string("in_tx_pool")) tx->in_tx_pool = it->second.get_value<bool>();
|
||||
else if (key == string("num_confirmations")) throw runtime_error("num_confirmations deserialization not implemented");
|
||||
else if (key == string("unlock_time")) throw runtime_error("unlock_time deserialization not implemented");
|
||||
else if (key == string("last_relayed_timestamp")) throw runtime_error("last_relayed_timestamp deserialization not implemented");
|
||||
else if (key == string("received_timestamp")) throw runtime_error("received_timestamp deserializationn not implemented");
|
||||
else if (key == string("is_double_spend_seen")) tx->is_double_spend_seen = it->second.get_value<bool>();
|
||||
else if (key == string("key")) tx->key = it->second.data();
|
||||
else if (key == string("fullHex")) tx->fullHex = it->second.data();
|
||||
else if (key == string("prunedHex")) tx->prunedHex = it->second.data();
|
||||
else if (key == string("prunableHex")) tx->prunableHex = it->second.data();
|
||||
else if (key == string("prunableHash")) tx->prunableHash = it->second.data();
|
||||
else if (key == string("full_hex")) tx->full_hex = it->second.data();
|
||||
else if (key == string("pruned_hex")) tx->pruned_hex = it->second.data();
|
||||
else if (key == string("prunable_hex")) tx->prunable_hex = it->second.data();
|
||||
else if (key == string("prunable_hash")) tx->prunable_hash = it->second.data();
|
||||
else if (key == string("size")) throw runtime_error("size deserialization not implemented");
|
||||
else if (key == string("weight")) throw runtime_error("weight deserialization not implemented");
|
||||
else if (key == string("vins")) throw runtime_error("vins deserializationn not implemented");
|
||||
else if (key == string("vouts")) throw runtime_error("vouts deserializationn not implemented");
|
||||
else if (key == string("outputIndices")) throw runtime_error("outputIndices deserialization not implemented");
|
||||
else if (key == string("m_output_indices")) throw runtime_error("m_output_indices deserialization not implemented");
|
||||
else if (key == string("metadata")) throw runtime_error("metadata deserialization not implemented");
|
||||
else if (key == string("commonTxSets")) throw runtime_error("commonTxSets deserialization not implemented");
|
||||
else if (key == string("common_tx_sets")) throw runtime_error("common_tx_sets deserialization not implemented");
|
||||
else if (key == string("extra")) throw runtime_error("extra deserialization not implemented");
|
||||
else if (key == string("rctSignatures")) throw runtime_error("rctSignatures deserialization not implemented");
|
||||
else if (key == string("rctSigPrunable")) throw runtime_error("rctSigPrunable deserialization not implemented");
|
||||
else if (key == string("isKeptByBlock")) tx->isKeptByBlock = it->second.get_value<bool>();
|
||||
else if (key == string("isFailed")) tx->isFailed = it->second.get_value<bool>();
|
||||
else if (key == string("lastFailedHeight")) throw runtime_error("lastFailedHeight deserialization not implemented");
|
||||
else if (key == string("lastFailedId")) tx->lastFailedId = it->second.data();
|
||||
else if (key == string("maxUsedBlockHeight")) throw runtime_error("maxUsedBlockHeight deserialization not implemented");
|
||||
else if (key == string("maxUsedBlockId")) tx->maxUsedBlockId = it->second.data();
|
||||
else if (key == string("rct_signatures")) throw runtime_error("rct_signatures deserialization not implemented");
|
||||
else if (key == string("rct_sig_prunable")) throw runtime_error("rct_sig_prunable deserialization not implemented");
|
||||
else if (key == string("is_kept_by_block")) tx->is_kept_by_block = it->second.get_value<bool>();
|
||||
else if (key == string("is_failed")) tx->is_failed = it->second.get_value<bool>();
|
||||
else if (key == string("last_failed_height")) throw runtime_error("last_failed_height deserialization not implemented");
|
||||
else if (key == string("last_failed_id")) tx->last_failed_id = it->second.data();
|
||||
else if (key == string("max_used_block_height")) throw runtime_error("max_used_block_height deserialization not implemented");
|
||||
else if (key == string("max_used_block_id")) tx->max_used_block_id = it->second.data();
|
||||
else if (key == string("signatures")) throw runtime_error("signatures deserialization not implemented");
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: fill this out
|
||||
void nodeToTxWallet(const boost::property_tree::ptree& node, shared_ptr<monero_tx_wallet> txWallet) {
|
||||
nodeToTx(node, txWallet);
|
||||
void node_to_tx_wallet(const boost::property_tree::ptree& node, shared_ptr<monero_tx_wallet> tx_wallet) {
|
||||
node_to_tx(node, tx_wallet);
|
||||
|
||||
for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) {
|
||||
string key = it->first;
|
||||
@@ -202,29 +202,29 @@ void nodeToTxWallet(const boost::property_tree::ptree& node, shared_ptr<monero_t
|
||||
}
|
||||
|
||||
shared_ptr<monero_tx_request> nodeToTxRequest(const boost::property_tree::ptree& node) {
|
||||
shared_ptr<monero_tx_request> txRequest = make_shared<monero_tx_request>();
|
||||
nodeToTxWallet(node, txRequest);
|
||||
shared_ptr<monero_tx_request> tx_request = make_shared<monero_tx_request>();
|
||||
node_to_tx_wallet(node, tx_request);
|
||||
|
||||
// initialize request from node
|
||||
for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) {
|
||||
string key = it->first;
|
||||
if (key == string("isOutgoing")) txRequest->isOutgoing = it->second.get_value<bool>();
|
||||
else if (key == string("isIncoming")) txRequest->isIncoming = it->second.get_value<bool>();
|
||||
else if (key == string("txIds")) for (boost::property_tree::ptree::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) txRequest->txIds.push_back(it2->second.data());
|
||||
else if (key == string("hasPaymentId")) txRequest->hasPaymentId = it->second.get_value<bool>();
|
||||
else if (key == string("paymentIds")) for (boost::property_tree::ptree::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) txRequest->paymentIds.push_back(it2->second.data());
|
||||
else if (key == string("height")) txRequest->height = it->second.get_value<uint64_t>();
|
||||
else if (key == string("minHeight")) txRequest->minHeight = it->second.get_value<uint64_t>();
|
||||
else if (key == string("maxHeight")) txRequest->maxHeight = it->second.get_value<uint64_t>();
|
||||
else if (key == string("includeOutputs")) txRequest->includeOutputs = it->second.get_value<bool>();
|
||||
else if (key == string("transferRequest")) txRequest->transferRequest = nodeToTransferRequest(it->second);
|
||||
else if (key == string("outputRequest")) txRequest->outputRequest = nodeToOutputRequest(it->second);
|
||||
if (key == string("is_outgoing")) tx_request->is_outgoing = it->second.get_value<bool>();
|
||||
else if (key == string("is_incoming")) tx_request->is_incoming = it->second.get_value<bool>();
|
||||
else if (key == string("tx_ids")) for (boost::property_tree::ptree::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) tx_request->tx_ids.push_back(it2->second.data());
|
||||
else if (key == string("has_payment_id")) tx_request->has_payment_id = it->second.get_value<bool>();
|
||||
else if (key == string("payment_ids")) for (boost::property_tree::ptree::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) tx_request->payment_ids.push_back(it2->second.data());
|
||||
else if (key == string("height")) tx_request->height = it->second.get_value<uint64_t>();
|
||||
else if (key == string("min_height")) tx_request->min_height = it->second.get_value<uint64_t>();
|
||||
else if (key == string("max_height")) tx_request->max_height = it->second.get_value<uint64_t>();
|
||||
else if (key == string("include_outputs")) tx_request->include_outputs = it->second.get_value<bool>();
|
||||
else if (key == string("transfer_request")) tx_request->transfer_request = node_to_transfer_request(it->second);
|
||||
else if (key == string("output_request")) tx_request->output_request = node_to_output_request(it->second);
|
||||
}
|
||||
|
||||
return txRequest;
|
||||
return tx_request;
|
||||
}
|
||||
|
||||
shared_ptr<monero_block> nodeToBlockRequest(const boost::property_tree::ptree& node) {
|
||||
shared_ptr<monero_block> node_to_block_request(const boost::property_tree::ptree& node) {
|
||||
shared_ptr<monero_block> block = make_shared<monero_block>();
|
||||
for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) {
|
||||
string key = it->first;
|
||||
@@ -238,7 +238,7 @@ shared_ptr<monero_block> nodeToBlockRequest(const boost::property_tree::ptree& n
|
||||
return block;
|
||||
}
|
||||
|
||||
shared_ptr<monero_destination> nodeToDestination(const boost::property_tree::ptree& node) {
|
||||
shared_ptr<monero_destination> node_to_destination(const boost::property_tree::ptree& node) {
|
||||
shared_ptr<monero_destination> destination = make_shared<monero_destination>();
|
||||
for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) {
|
||||
string key = it->first;
|
||||
@@ -250,19 +250,19 @@ shared_ptr<monero_destination> nodeToDestination(const boost::property_tree::ptr
|
||||
|
||||
// ------------------------- PUBLIC STATIC UTILITIES --------------------------
|
||||
|
||||
void monero_utils::jsonToBinary(const std::string &json, std::string &bin) {
|
||||
void monero_utils::json_to_binary(const std::string &json, std::string &bin) {
|
||||
epee::serialization::portable_storage ps;
|
||||
ps.load_from_json(json);
|
||||
ps.store_to_binary(bin);
|
||||
}
|
||||
|
||||
void monero_utils::binaryToJson(const std::string &bin, std::string &json) {
|
||||
void monero_utils::binary_to_json(const std::string &bin, std::string &json) {
|
||||
epee::serialization::portable_storage ps;
|
||||
ps.load_from_binary(bin);
|
||||
ps.dump_as_json(json);
|
||||
}
|
||||
|
||||
void monero_utils::binaryBlocksToJson(const std::string &bin, std::string &json) {
|
||||
void monero_utils::binary_blocks_to_json(const std::string &bin, std::string &json) {
|
||||
|
||||
// load binary rpc response to struct
|
||||
cryptonote::COMMAND_RPC_GET_BLOCKS_BY_HEIGHT::response resp_struct;
|
||||
@@ -314,7 +314,7 @@ void monero_utils::binaryBlocksToJson(const std::string &bin, std::string &json)
|
||||
json = ss.str();
|
||||
}
|
||||
|
||||
shared_ptr<monero_tx_request> monero_utils::deserializeTxRequest(const string& txRequestStr) {
|
||||
shared_ptr<monero_tx_request> monero_utils::deserialize_tx_request(const string& txRequestStr) {
|
||||
|
||||
// deserialize tx request string to property rooted at block
|
||||
std::istringstream iss = txRequestStr.empty() ? std::istringstream() : std::istringstream(txRequestStr);
|
||||
@@ -322,73 +322,73 @@ shared_ptr<monero_tx_request> monero_utils::deserializeTxRequest(const string& t
|
||||
boost::property_tree::read_json(iss, blockNode);
|
||||
|
||||
// convert request property tree to block
|
||||
shared_ptr<monero_block> block = nodeToBlockRequest(blockNode);
|
||||
shared_ptr<monero_block> block = node_to_block_request(blockNode);
|
||||
|
||||
// get tx request
|
||||
shared_ptr<monero_tx_request> txRequest = static_pointer_cast<monero_tx_request>(block->txs[0]);
|
||||
shared_ptr<monero_tx_request> tx_request = static_pointer_cast<monero_tx_request>(block->txs[0]);
|
||||
|
||||
// return deserialized request
|
||||
return txRequest;
|
||||
return tx_request;
|
||||
}
|
||||
|
||||
shared_ptr<monero_transfer_request> monero_utils::deserializeTransferRequest(const string& transferRequestStr) {
|
||||
shared_ptr<monero_transfer_request> monero_utils::deserialize_transfer_request(const string& transfer_request_str) {
|
||||
|
||||
// deserialize transfer request string to property rooted at block
|
||||
std::istringstream iss = transferRequestStr.empty() ? std::istringstream() : std::istringstream(transferRequestStr);
|
||||
std::istringstream iss = transfer_request_str.empty() ? std::istringstream() : std::istringstream(transfer_request_str);
|
||||
boost::property_tree::ptree blockNode;
|
||||
boost::property_tree::read_json(iss, blockNode);
|
||||
|
||||
// convert request property tree to block
|
||||
shared_ptr<monero_block> block = nodeToBlockRequest(blockNode);
|
||||
shared_ptr<monero_block> block = node_to_block_request(blockNode);
|
||||
|
||||
// return mpty request if no txs
|
||||
if (block->txs.empty()) return make_shared<monero_transfer_request>();
|
||||
|
||||
// get tx request
|
||||
shared_ptr<monero_tx_request> txRequest = static_pointer_cast<monero_tx_request>(block->txs[0]);
|
||||
shared_ptr<monero_tx_request> tx_request = static_pointer_cast<monero_tx_request>(block->txs[0]);
|
||||
|
||||
// get / create transfer request
|
||||
shared_ptr<monero_transfer_request> transferRequest = txRequest->transferRequest == boost::none ? make_shared<monero_transfer_request>() : *txRequest->transferRequest;
|
||||
shared_ptr<monero_transfer_request> transfer_request = tx_request->transfer_request == boost::none ? make_shared<monero_transfer_request>() : *tx_request->transfer_request;
|
||||
|
||||
// transfer request references tx request but not the other way around to avoid circular loop // TODO: could add check within meetsCriterias()
|
||||
transferRequest->txRequest = txRequest;
|
||||
txRequest->transferRequest = boost::none;
|
||||
transfer_request->tx_request = tx_request;
|
||||
tx_request->transfer_request = boost::none;
|
||||
|
||||
// return deserialized request
|
||||
return transferRequest;
|
||||
return transfer_request;
|
||||
}
|
||||
|
||||
shared_ptr<monero_output_request> monero_utils::deserializeOutputRequest(const string& outputRequestStr) {
|
||||
shared_ptr<monero_output_request> monero_utils::deserialize_output_request(const string& output_request_str) {
|
||||
|
||||
// deserialize output request string to property rooted at block
|
||||
std::istringstream iss = outputRequestStr.empty() ? std::istringstream() : std::istringstream(outputRequestStr);
|
||||
std::istringstream iss = output_request_str.empty() ? std::istringstream() : std::istringstream(output_request_str);
|
||||
boost::property_tree::ptree blockNode;
|
||||
boost::property_tree::read_json(iss, blockNode);
|
||||
|
||||
// convert request property tree to block
|
||||
shared_ptr<monero_block> block = nodeToBlockRequest(blockNode);
|
||||
shared_ptr<monero_block> block = node_to_block_request(blockNode);
|
||||
|
||||
// empty request if no txs
|
||||
if (block->txs.empty()) return make_shared<monero_output_request>();
|
||||
|
||||
// get tx request
|
||||
shared_ptr<monero_tx_request> txRequest = static_pointer_cast<monero_tx_request>(block->txs[0]);
|
||||
shared_ptr<monero_tx_request> tx_request = static_pointer_cast<monero_tx_request>(block->txs[0]);
|
||||
|
||||
// get / create output request
|
||||
shared_ptr<monero_output_request> outputRequest = txRequest->outputRequest == boost::none ? make_shared<monero_output_request>() : *txRequest->outputRequest;
|
||||
shared_ptr<monero_output_request> output_request = tx_request->output_request == boost::none ? make_shared<monero_output_request>() : *tx_request->output_request;
|
||||
|
||||
// output request references tx request but not the other way around to avoid circular loop // TODO: could add check within meetsCriterias()
|
||||
outputRequest->txRequest = txRequest;
|
||||
txRequest->outputRequest = boost::none;
|
||||
output_request->tx_request = tx_request;
|
||||
tx_request->output_request = boost::none;
|
||||
|
||||
// return deserialized request
|
||||
return outputRequest;
|
||||
return output_request;
|
||||
}
|
||||
|
||||
shared_ptr<monero_send_request> monero_utils::deserializeSendRequest(const string& sendRequestStr) {
|
||||
shared_ptr<monero_send_request> monero_utils::deserialize_send_request(const string& send_request_str) {
|
||||
|
||||
// deserialize send request json to property node
|
||||
std::istringstream iss = sendRequestStr.empty() ? std::istringstream() : std::istringstream(sendRequestStr);
|
||||
std::istringstream iss = send_request_str.empty() ? std::istringstream() : std::istringstream(send_request_str);
|
||||
boost::property_tree::ptree node;
|
||||
boost::property_tree::read_json(iss, node);
|
||||
|
||||
@@ -399,33 +399,33 @@ shared_ptr<monero_send_request> monero_utils::deserializeSendRequest(const strin
|
||||
if (key == string("destinations")) {
|
||||
boost::property_tree::ptree destinationsNode = it->second;
|
||||
for (boost::property_tree::ptree::const_iterator it2 = destinationsNode.begin(); it2 != destinationsNode.end(); ++it2) {
|
||||
sendRequest->destinations.push_back(nodeToDestination(it2->second));
|
||||
sendRequest->destinations.push_back(node_to_destination(it2->second));
|
||||
}
|
||||
}
|
||||
else if (key == string("paymentId")) sendRequest->paymentId = it->second.data();
|
||||
else if (key == string("priority")) throw runtime_error("deserializeSendRequest() paymentId not implemented");
|
||||
else if (key == string("payment_id")) sendRequest->payment_id = it->second.data();
|
||||
else if (key == string("priority")) throw runtime_error("deserialize_send_request() payment_id not implemented");
|
||||
else if (key == string("mixin")) sendRequest->mixin = it->second.get_value<uint32_t>();
|
||||
else if (key == string("ringSize")) sendRequest->ringSize = it->second.get_value<uint32_t>();
|
||||
else if (key == string("fee")) sendRequest->fee = it->second.get_value<uint64_t>();
|
||||
else if (key == string("accountIndex")) sendRequest->accountIndex = it->second.get_value<uint32_t>();
|
||||
else if (key == string("subaddressIndices")) for (boost::property_tree::ptree::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) sendRequest->subaddressIndices.push_back(it2->second.get_value<uint32_t>());
|
||||
else if (key == string("unlockTime")) sendRequest->unlockTime = it->second.get_value<uint64_t>();
|
||||
else if (key == string("canSplit")) sendRequest->canSplit = it->second.get_value<bool>();
|
||||
else if (key == string("doNotRelay")) sendRequest->doNotRelay = it->second.get_value<bool>();
|
||||
else if (key == string("account_index")) sendRequest->account_index = it->second.get_value<uint32_t>();
|
||||
else if (key == string("subaddress_indices")) for (boost::property_tree::ptree::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) sendRequest->subaddress_indices.push_back(it2->second.get_value<uint32_t>());
|
||||
else if (key == string("unlock_time")) sendRequest->unlock_time = it->second.get_value<uint64_t>();
|
||||
else if (key == string("can_split")) sendRequest->can_split = it->second.get_value<bool>();
|
||||
else if (key == string("do_not_relay")) sendRequest->do_not_relay = it->second.get_value<bool>();
|
||||
else if (key == string("note")) sendRequest->note = it->second.data();
|
||||
else if (key == string("recipientName")) sendRequest->recipientName = it->second.data();
|
||||
else if (key == string("belowAmount")) sendRequest->belowAmount = it->second.get_value<uint64_t>();
|
||||
else if (key == string("sweepEachSubaddress")) sendRequest->sweepEachSubaddress = it->second.get_value<bool>();
|
||||
else if (key == string("keyImage")) sendRequest->keyImage = it->second.data();
|
||||
else if (key == string("receipient_name")) sendRequest->receipient_name = it->second.data();
|
||||
else if (key == string("below_amount")) sendRequest->below_amount = it->second.get_value<uint64_t>();
|
||||
else if (key == string("sweep_each_subaddress")) sendRequest->sweep_each_subaddress = it->second.get_value<bool>();
|
||||
else if (key == string("key_image")) sendRequest->key_image = it->second.data();
|
||||
}
|
||||
|
||||
return sendRequest;
|
||||
}
|
||||
|
||||
vector<shared_ptr<monero_key_image>> monero_utils::deserializeKeyImages(const string& keyImagesJson) {
|
||||
vector<shared_ptr<monero_key_image>> monero_utils::deserialize_key_images(const string& key_images_json) {
|
||||
|
||||
// deserialize json to property node
|
||||
std::istringstream iss = keyImagesJson.empty() ? std::istringstream() : std::istringstream(keyImagesJson);
|
||||
std::istringstream iss = key_images_json.empty() ? std::istringstream() : std::istringstream(key_images_json);
|
||||
boost::property_tree::ptree node;
|
||||
boost::property_tree::read_json(iss, node);
|
||||
|
||||
@@ -435,10 +435,10 @@ vector<shared_ptr<monero_key_image>> monero_utils::deserializeKeyImages(const st
|
||||
string key = it->first;
|
||||
if (key == string("keyImages")) {
|
||||
for (boost::property_tree::ptree::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) {
|
||||
keyImages.push_back(nodeToKeyImage(it2->second));
|
||||
keyImages.push_back(node_to_key_image(it2->second));
|
||||
}
|
||||
}
|
||||
else MWARNING("WARNING MoneroWalletJni::deserializeKeyImages() unrecognized key: " << key);
|
||||
else MWARNING("WARNING MoneroWalletJni::deserialize_key_images() unrecognized key: " << key);
|
||||
}
|
||||
return keyImages;
|
||||
}
|
||||
@@ -491,53 +491,53 @@ boost::property_tree::ptree monero_utils::to_property_tree(const vector<uint64_t
|
||||
return numsNode;
|
||||
}
|
||||
|
||||
shared_ptr<monero_block> monero_utils::cnBlockToBlock(const cryptonote::block& cnBlock) {
|
||||
cryptonote::block temp = cnBlock;
|
||||
shared_ptr<monero_block> monero_utils::cn_block_to_block(const cryptonote::block& cn_block) {
|
||||
cryptonote::block temp = cn_block;
|
||||
cout << cryptonote::obj_to_json_str(temp) << endl;
|
||||
shared_ptr<monero_block> block = make_shared<monero_block>();
|
||||
block->majorVersion = cnBlock.major_version;
|
||||
block->minorVersion = cnBlock.minor_version;
|
||||
block->timestamp = cnBlock.timestamp;
|
||||
block->prevId = epee::string_tools::pod_to_hex(cnBlock.prev_id);
|
||||
block->nonce = cnBlock.nonce;
|
||||
block->minerTx = monero_utils::cnTxToTx(cnBlock.miner_tx);
|
||||
for (const crypto::hash& txHash : cnBlock.tx_hashes) {
|
||||
block->txIds.push_back(epee::string_tools::pod_to_hex(txHash));
|
||||
block->major_version = cn_block.major_version;
|
||||
block->minor_version = cn_block.minor_version;
|
||||
block->timestamp = cn_block.timestamp;
|
||||
block->prev_id = epee::string_tools::pod_to_hex(cn_block.prev_id);
|
||||
block->nonce = cn_block.nonce;
|
||||
block->miner_tx = monero_utils::cn_tx_to_tx(cn_block.miner_tx);
|
||||
for (const crypto::hash& txHash : cn_block.tx_hashes) {
|
||||
block->tx_ids.push_back(epee::string_tools::pod_to_hex(txHash));
|
||||
}
|
||||
return block;
|
||||
}
|
||||
|
||||
shared_ptr<monero_tx> monero_utils::cnTxToTx(const cryptonote::transaction& cnTx, bool initAsTxWallet) {
|
||||
shared_ptr<monero_tx> tx = initAsTxWallet ? make_shared<monero_tx_wallet>() : make_shared<monero_tx>();
|
||||
tx->version = cnTx.version;
|
||||
tx->unlockTime = cnTx.unlock_time;
|
||||
tx->id = epee::string_tools::pod_to_hex(cnTx.hash);
|
||||
tx->extra = cnTx.extra;
|
||||
shared_ptr<monero_tx> monero_utils::cn_tx_to_tx(const cryptonote::transaction& cn_tx, bool init_as_tx_wallet) {
|
||||
shared_ptr<monero_tx> tx = init_as_tx_wallet ? make_shared<monero_tx_wallet>() : make_shared<monero_tx>();
|
||||
tx->version = cn_tx.version;
|
||||
tx->unlock_time = cn_tx.unlock_time;
|
||||
tx->id = epee::string_tools::pod_to_hex(cn_tx.hash);
|
||||
tx->extra = cn_tx.extra;
|
||||
|
||||
// init vins
|
||||
for (const txin_v& cnVin : cnTx.vin) {
|
||||
for (const txin_v& cnVin : cn_tx.vin) {
|
||||
if (cnVin.which() != 0 && cnVin.which() != 3) throw runtime_error("Unsupported variant type");
|
||||
if (tx->isMinerTx == boost::none) tx->isMinerTx = cnVin.which() == 0;
|
||||
if (tx->is_miner_tx == boost::none) tx->is_miner_tx = cnVin.which() == 0;
|
||||
if (cnVin.which() != 3) continue; // only process txin_to_key of variant TODO: support other types, like 0 "gen" which is miner tx?
|
||||
shared_ptr<monero_output> vin = initAsTxWallet ? make_shared<monero_output_wallet>() : make_shared<monero_output>();
|
||||
shared_ptr<monero_output> vin = init_as_tx_wallet ? make_shared<monero_output_wallet>() : make_shared<monero_output>();
|
||||
vin->tx = tx;
|
||||
tx->vins.push_back(vin);
|
||||
const txin_to_key& txin = boost::get<txin_to_key>(cnVin);
|
||||
vin->amount = txin.amount;
|
||||
vin->ringOutputIndices = txin.key_offsets;
|
||||
vin->ring_output_indices = txin.key_offsets;
|
||||
crypto::key_image cnKeyImage = txin.k_image;
|
||||
vin->keyImage = make_shared<monero_key_image>();
|
||||
vin->keyImage.get()->hex = epee::string_tools::pod_to_hex(cnKeyImage);
|
||||
vin->key_image = make_shared<monero_key_image>();
|
||||
vin->key_image.get()->hex = epee::string_tools::pod_to_hex(cnKeyImage);
|
||||
}
|
||||
|
||||
// init vouts
|
||||
for (const tx_out& cnVout : cnTx.vout) {
|
||||
shared_ptr<monero_output> vout = initAsTxWallet ? make_shared<monero_output_wallet>() : make_shared<monero_output>();
|
||||
for (const tx_out& cnVout : cn_tx.vout) {
|
||||
shared_ptr<monero_output> vout = init_as_tx_wallet ? make_shared<monero_output_wallet>() : make_shared<monero_output>();
|
||||
vout->tx = tx;
|
||||
tx->vouts.push_back(vout);
|
||||
vout->amount = cnVout.amount;
|
||||
const crypto::public_key& cnStealthPublicKey = boost::get<txout_to_key>(cnVout.target).key;
|
||||
vout->stealthPublicKey = epee::string_tools::pod_to_hex(cnStealthPublicKey);
|
||||
vout->stealth_public_key = epee::string_tools::pod_to_hex(cnStealthPublicKey);
|
||||
}
|
||||
|
||||
return tx;
|
||||
|
||||
+38
-38
@@ -50,8 +50,8 @@
|
||||
* Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
|
||||
*/
|
||||
|
||||
#ifndef MoneroUtils_h
|
||||
#define MoneroUtils_h
|
||||
#ifndef monero_utils_h
|
||||
#define monero_utils_h
|
||||
|
||||
#include "wallet/monero_wallet.h"
|
||||
#include "cryptonote_basic/cryptonote_basic.h"
|
||||
@@ -66,41 +66,41 @@ namespace monero_utils
|
||||
using namespace std;
|
||||
using namespace cryptonote;
|
||||
|
||||
void jsonToBinary(const std::string &json, std::string &bin);
|
||||
void json_to_binary(const std::string &json, std::string &bin);
|
||||
|
||||
void binaryToJson(const std::string &bin, std::string &json);
|
||||
void binary_to_json(const std::string &bin, std::string &json);
|
||||
|
||||
void binaryBlocksToJson(const std::string &bin, std::string &json);
|
||||
void binary_blocks_to_json(const std::string &bin, std::string &json);
|
||||
|
||||
shared_ptr<monero_tx_request> deserializeTxRequest(const string& txRequestStr);
|
||||
shared_ptr<monero_tx_request> deserialize_tx_request(const string& txRequestStr);
|
||||
|
||||
shared_ptr<monero_transfer_request> deserializeTransferRequest(const string& transferRequestStr);
|
||||
shared_ptr<monero_transfer_request> deserialize_transfer_request(const string& transfer_request_str);
|
||||
|
||||
shared_ptr<monero_output_request> deserializeOutputRequest(const string& outputRequestStr);
|
||||
shared_ptr<monero_output_request> deserialize_output_request(const string& output_request_str);
|
||||
|
||||
shared_ptr<monero_send_request> deserializeSendRequest(const string& sendRequestStr);
|
||||
shared_ptr<monero_send_request> deserialize_send_request(const string& send_request_str);
|
||||
|
||||
vector<shared_ptr<monero_key_image>> deserializeKeyImages(const string& keyImagesJson);
|
||||
vector<shared_ptr<monero_key_image>> deserialize_key_images(const string& key_images_json);
|
||||
|
||||
string serialize(const boost::property_tree::ptree& node);
|
||||
|
||||
/**
|
||||
* Convert a Monero Core cryptonote::block to a block in this library's native model.
|
||||
*
|
||||
* @param cnBlock is the Core block to convert
|
||||
* @param cn_block is the Core block to convert
|
||||
* @return a block in this library's native model
|
||||
*/
|
||||
shared_ptr<monero_block> cnBlockToBlock(const cryptonote::block& cnBlock);
|
||||
shared_ptr<monero_block> cn_block_to_block(const cryptonote::block& cn_block);
|
||||
|
||||
|
||||
/**
|
||||
* Convert a Monero Core crpytonote::transaction to a transaction in this library's
|
||||
* native model.
|
||||
*
|
||||
* @param cnTx is the Core transaction to convert
|
||||
* @param initAsTxWallet specifies if a monero_tx xor monero_tx_wallet should be initialized
|
||||
* @param cn_tx is the Core transaction to convert
|
||||
* @param init_as_tx_wallet specifies if a monero_tx xor monero_tx_wallet should be initialized
|
||||
*/
|
||||
shared_ptr<monero_tx> cnTxToTx(const cryptonote::transaction& cnTx, bool initAsTxWallet = false);
|
||||
shared_ptr<monero_tx> cn_tx_to_tx(const cryptonote::transaction& cn_tx, bool init_as_tx_wallet = false);
|
||||
|
||||
/**
|
||||
* Modified from core_rpc_server.cpp to return a string.
|
||||
@@ -145,75 +145,75 @@ namespace monero_utils
|
||||
|
||||
// TODO: refactor common template code
|
||||
template <class T, typename std::enable_if<std::is_same<T, string>::value, T>::type* = nullptr>
|
||||
boost::optional<T> reconcile(const boost::optional<T>& val1, const boost::optional<T>& val2, boost::optional<bool> resolveDefined, boost::optional<bool> resolveTrue, boost::optional<bool> resolveMax, const string& errMsg = "") {
|
||||
boost::optional<T> reconcile(const boost::optional<T>& val1, const boost::optional<T>& val2, boost::optional<bool> resolve_defined, boost::optional<bool> resolve_true, boost::optional<bool> resolve_max, const string& err_msg = "") {
|
||||
|
||||
// check for equality
|
||||
if (val1 == val2) return val1;
|
||||
|
||||
// resolve one value none
|
||||
if (val1 == boost::none || val2 == boost::none) {
|
||||
if (resolveDefined != boost::none && *resolveDefined == false) return boost::none;
|
||||
if (resolve_defined != boost::none && *resolve_defined == false) return boost::none;
|
||||
else return val1 == boost::none ? val2 : val1;
|
||||
}
|
||||
|
||||
throw runtime_error(string("Cannot reconcile strings: ") + to_string(val1) + string(" vs ") + to_string(val2) + (!errMsg.empty() ? string(". ") + errMsg : string("")));
|
||||
throw runtime_error(string("Cannot reconcile strings: ") + to_string(val1) + string(" vs ") + to_string(val2) + (!err_msg.empty() ? string(". ") + err_msg : string("")));
|
||||
}
|
||||
template <class T, typename std::enable_if<std::is_same<T, string>::value, T>::type* = nullptr>
|
||||
boost::optional<T> reconcile(const boost::optional<T>& val1, const boost::optional<T>& val2, const string& errMsg = "") {
|
||||
return reconcile(val1, val2, boost::none, boost::none, boost::none, errMsg);
|
||||
boost::optional<T> reconcile(const boost::optional<T>& val1, const boost::optional<T>& val2, const string& err_msg = "") {
|
||||
return reconcile(val1, val2, boost::none, boost::none, boost::none, err_msg);
|
||||
}
|
||||
|
||||
template <class T, typename std::enable_if<std::is_integral<T>::value, T>::type* = nullptr>
|
||||
boost::optional<T> reconcile(const boost::optional<T>& val1, const boost::optional<T>& val2, boost::optional<bool> resolveDefined, boost::optional<bool> resolveTrue, boost::optional<bool> resolveMax, const string& errMsg = "") {
|
||||
boost::optional<T> reconcile(const boost::optional<T>& val1, const boost::optional<T>& val2, boost::optional<bool> resolve_defined, boost::optional<bool> resolve_true, boost::optional<bool> resolve_max, const string& err_msg = "") {
|
||||
|
||||
// check for equality
|
||||
if (val1 == val2) return val1;
|
||||
|
||||
// resolve one value none
|
||||
if (val1 == boost::none || val2 == boost::none) {
|
||||
if (resolveDefined != boost::none && *resolveDefined == false) return boost::none;
|
||||
if (resolve_defined != boost::none && *resolve_defined == false) return boost::none;
|
||||
else return val1 == boost::none ? val2 : val1;
|
||||
}
|
||||
|
||||
// resolve different numbers
|
||||
if (resolveMax != boost::none) {
|
||||
return *resolveMax ? max(*val1, *val2) : min(*val1, *val2);
|
||||
if (resolve_max != boost::none) {
|
||||
return *resolve_max ? max(*val1, *val2) : min(*val1, *val2);
|
||||
}
|
||||
|
||||
// throw runtime_error("Cannot reconcile values " + val1 + " and " + val2 + " with config: [" + resolveDefined + ", " + resolveTrue + ", " + resolveMax + "]", val1, val2);
|
||||
throw runtime_error(string("Cannot reconcile integrals: ") + to_string(val1) + string(" vs ") + to_string(val2) + (!errMsg.empty() ? string(". ") + errMsg : string("")));
|
||||
// throw runtime_error("Cannot reconcile values " + val1 + " and " + val2 + " with config: [" + resolve_defined + ", " + resolve_true + ", " + resolve_max + "]", val1, val2);
|
||||
throw runtime_error(string("Cannot reconcile integrals: ") + to_string(val1) + string(" vs ") + to_string(val2) + (!err_msg.empty() ? string(". ") + err_msg : string("")));
|
||||
}
|
||||
template <class T, typename std::enable_if<std::is_integral<T>::value, T>::type* = nullptr>
|
||||
boost::optional<T> reconcile(const boost::optional<T>& val1, const boost::optional<T>& val2, const string& errMsg = "") {
|
||||
return reconcile(val1, val2, boost::none, boost::none, boost::none, errMsg);
|
||||
boost::optional<T> reconcile(const boost::optional<T>& val1, const boost::optional<T>& val2, const string& err_msg = "") {
|
||||
return reconcile(val1, val2, boost::none, boost::none, boost::none, err_msg);
|
||||
}
|
||||
|
||||
template <class T, typename std::enable_if<std::is_same<T, bool>::value, T>::type>
|
||||
boost::optional<T> reconcile(const boost::optional<T>& val1, const boost::optional<T>& val2, boost::optional<bool> resolveDefined, boost::optional<bool> resolveTrue, boost::optional<bool> resolveMax, const string& errMsg = "") {
|
||||
boost::optional<T> reconcile(const boost::optional<T>& val1, const boost::optional<T>& val2, boost::optional<bool> resolve_defined, boost::optional<bool> resolve_true, boost::optional<bool> resolve_max, const string& err_msg = "") {
|
||||
|
||||
// check for equality
|
||||
if (val1 == val2) return val1;
|
||||
|
||||
// resolve one value none
|
||||
if (val1 == boost::none || val2 == boost::none) {
|
||||
if (resolveDefined != boost::none && *resolveDefined == false) return boost::none;
|
||||
if (resolve_defined != boost::none && *resolve_defined == false) return boost::none;
|
||||
else return val1 == boost::none ? val2 : val1;
|
||||
}
|
||||
|
||||
// resolve different booleans
|
||||
if (resolveTrue != boost::none) {
|
||||
return val1 == resolveTrue ? val1 : val2; // if resolve true, return true, else return false
|
||||
if (resolve_true != boost::none) {
|
||||
return val1 == resolve_true ? val1 : val2; // if resolve true, return true, else return false
|
||||
} else {
|
||||
throw runtime_error(string("Cannot reconcile booleans: ") + to_string(val1) + string(" vs ") + to_string(val2) + (!errMsg.empty() ? string(". ") + errMsg : string("")));
|
||||
throw runtime_error(string("Cannot reconcile booleans: ") + to_string(val1) + string(" vs ") + to_string(val2) + (!err_msg.empty() ? string(". ") + err_msg : string("")));
|
||||
}
|
||||
}
|
||||
template <class T, typename std::enable_if<std::is_same<T, bool>::value, T>::type>
|
||||
boost::optional<T> reconcile(const boost::optional<T>& val1, const boost::optional<T>& val2, const string& errMsg = "") {
|
||||
return reconcile(val1, val2, boost::none, boost::none, boost::none, errMsg);
|
||||
boost::optional<T> reconcile(const boost::optional<T>& val1, const boost::optional<T>& val2, const string& err_msg = "") {
|
||||
return reconcile(val1, val2, boost::none, boost::none, boost::none, err_msg);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
vector<T> reconcile(const vector<T>& v1, const vector<T>& v2, const string& errMsg = "") {
|
||||
vector<T> reconcile(const vector<T>& v1, const vector<T>& v2, const string& err_msg = "") {
|
||||
|
||||
// check for equality
|
||||
if (v1 == v2) return v1;
|
||||
@@ -223,7 +223,7 @@ namespace monero_utils
|
||||
if (v2.empty()) return v1;
|
||||
|
||||
// otherwise cannot reconcile
|
||||
throw runtime_error("Cannot reconcile vectors" + (!errMsg.empty() ? string(". ") + errMsg : string("")));
|
||||
throw runtime_error("Cannot reconcile vectors" + (!err_msg.empty() ? string(". ") + err_msg : string("")));
|
||||
}
|
||||
|
||||
// template <class T>
|
||||
@@ -231,4 +231,4 @@ namespace monero_utils
|
||||
// return reconcile(val1, val2, boost::none, boost::none, boost::none);
|
||||
// }
|
||||
}
|
||||
#endif /* MoneroUtils_h */
|
||||
#endif /* monero_utils_h */
|
||||
|
||||
+342
-342
File diff suppressed because it is too large
Load Diff
+30
-30
@@ -375,19 +375,19 @@ namespace monero {
|
||||
/**
|
||||
* Get an integrated address from a standard address and a payment id.
|
||||
*
|
||||
* @param standardAddress is the integrated addresse's standard address (defaults to wallet's primary address)
|
||||
* @param paymentId is the integrated addresse's payment id (defaults to randomly generating new payment id)
|
||||
* @param standard_address is the integrated addresse's standard address (defaults to wallet's primary address)
|
||||
* @param payment_id is the integrated addresse's payment id (defaults to randomly generating new payment id)
|
||||
* @return the integrated address
|
||||
*/
|
||||
monero_integrated_address get_integrated_address(const string& standardAddress = "", const string& paymentId = "") const;
|
||||
monero_integrated_address get_integrated_address(const string& standard_address = "", const string& payment_id = "") const;
|
||||
|
||||
/**
|
||||
* Decode an integrated address to get its standard address and payment id.
|
||||
*
|
||||
* @param integratedAddress is an integrated address to decode
|
||||
* @param integrated_address is an integrated address to decode
|
||||
* @return the decoded integrated address including standard address and payment id
|
||||
*/
|
||||
monero_integrated_address decode_integrated_address(const string& integratedAddress) const;
|
||||
monero_integrated_address decode_integrated_address(const string& integrated_address) const;
|
||||
|
||||
/**
|
||||
* Set the wallet's listener to receive wallet notifications.
|
||||
@@ -599,10 +599,10 @@ namespace monero {
|
||||
* Get subaddresses in an account.
|
||||
*
|
||||
* @param accountIdx specifies the account to get subaddresses within
|
||||
* @param subaddressIndices are specific subaddresses to get (optional)
|
||||
* @param subaddress_indices are specific subaddresses to get (optional)
|
||||
* @return the retrieved subaddresses
|
||||
*/
|
||||
vector<monero_subaddress> get_subaddresses(const uint32_t accountIdx, const vector<uint32_t>& subaddressIndices) const;
|
||||
vector<monero_subaddress> get_subaddresses(const uint32_t accountIdx, const vector<uint32_t>& subaddress_indices) const;
|
||||
|
||||
/**
|
||||
* Get a subaddress.
|
||||
@@ -641,10 +641,10 @@ namespace monero {
|
||||
// /**
|
||||
// * Get wallet transactions by id.
|
||||
// *
|
||||
// * @param txIds are ids of transactions to get
|
||||
// * @param tx_ids are ids of transactions to get
|
||||
// * @return the identified transactions
|
||||
// */
|
||||
// public List<monero_tx_wallet> get_txs(Collection<string> txIds);
|
||||
// public List<monero_tx_wallet> get_txs(Collection<string> tx_ids);
|
||||
|
||||
/**
|
||||
* Get wallet transactions. Wallet transactions contain one or more
|
||||
@@ -791,24 +791,24 @@ namespace monero {
|
||||
// * Create and relay a transaction which transfers funds from this wallet to
|
||||
// * a destination address.
|
||||
// *
|
||||
// * @param accountIndex is the index of the account to draw funds from
|
||||
// * @param account_index is the index of the account to draw funds from
|
||||
// * @param address is the destination address to send funds to
|
||||
// * @param sendAmount is the amount being sent
|
||||
// * @return the resulting transaction
|
||||
// */
|
||||
// public monero_tx_wallet send(int accountIndex, string address, BigInteger sendAmount);
|
||||
// public monero_tx_wallet send(int account_index, string address, BigInteger sendAmount);
|
||||
//
|
||||
// /**
|
||||
// * Create and relay a transaction which transfers funds from this wallet to
|
||||
// * a destination address.
|
||||
// *
|
||||
// * @param accountIndex is the index of the account to draw funds from
|
||||
// * @param account_index is the index of the account to draw funds from
|
||||
// * @param address is the destination address to send funds to
|
||||
// * @param sendAmount is the amount being sent
|
||||
// * @param priority is the send priority (default normal)
|
||||
// * @return the resulting transaction
|
||||
// */
|
||||
// public monero_tx_wallet send(int accountIndex, string address, BigInteger sendAmount, monero_send_priority priority);
|
||||
// public monero_tx_wallet send(int account_index, string address, BigInteger sendAmount, monero_send_priority priority);
|
||||
//
|
||||
// /**
|
||||
// * Create and relay (depending on configuration) one or more transactions
|
||||
@@ -823,24 +823,24 @@ namespace monero {
|
||||
// * Create and relay one or more transactions which transfer funds from this
|
||||
// * wallet to one or more destination.
|
||||
// *
|
||||
// * @param accountIndex is the index of the account to draw funds from
|
||||
// * @param account_index is the index of the account to draw funds from
|
||||
// * @param address is the destination address to send funds to
|
||||
// * @param sendAmount is the amount being sent
|
||||
// * @return the resulting transactions
|
||||
// */
|
||||
// public List<monero_tx_wallet> send_split(int accountIndex, string address, BigInteger sendAmount);
|
||||
// public List<monero_tx_wallet> send_split(int account_index, string address, BigInteger sendAmount);
|
||||
//
|
||||
// /**
|
||||
// * Create and relay one or more transactions which transfer funds from this
|
||||
// * wallet to one or more destination.
|
||||
// *
|
||||
// * @param accountIndex is the index of the account to draw funds from
|
||||
// * @param account_index is the index of the account to draw funds from
|
||||
// * @param address is the destination address to send funds to
|
||||
// * @param sendAmount is the amount being sent
|
||||
// * @param priority is the send priority (default normal)
|
||||
// * @return the resulting transactions
|
||||
// */
|
||||
// public List<monero_tx_wallet> send_split(int accountIndex, string address, BigInteger sendAmount, monero_send_priority priority);
|
||||
// public List<monero_tx_wallet> send_split(int account_index, string address, BigInteger sendAmount, monero_send_priority priority);
|
||||
|
||||
/**
|
||||
* Sweep an output with a given key image.
|
||||
@@ -854,20 +854,20 @@ namespace monero {
|
||||
// * Sweep an output with a given key image.
|
||||
// *
|
||||
// * @param address is the destination address to send to
|
||||
// * @param keyImage is the key image hex of the output to sweep
|
||||
// * @param key_image is the key image hex of the output to sweep
|
||||
// * @return the resulting transaction from sweeping an output
|
||||
// */
|
||||
// public monero_tx_wallet sweep_output(string address, string keyImage);
|
||||
// public monero_tx_wallet sweep_output(string address, string key_image);
|
||||
//
|
||||
// /**
|
||||
// * Sweep an output with a given key image.
|
||||
// *
|
||||
// * @param address is the destination address to send to
|
||||
// * @param keyImage is the key image hex of the output to sweep
|
||||
// * @param key_image is the key image hex of the output to sweep
|
||||
// * @param priority is the transaction priority (optional)
|
||||
// * @return the resulting transaction from sweeping an output
|
||||
// */
|
||||
// public monero_tx_wallet sweep_output(string address, string keyImage, monero_send_priority priority);
|
||||
// public monero_tx_wallet sweep_output(string address, string key_image, monero_send_priority priority);
|
||||
//
|
||||
// /**
|
||||
// * Sweep a subaddress's unlocked funds to an address.
|
||||
@@ -916,10 +916,10 @@ namespace monero {
|
||||
/**
|
||||
* Sweep all unmixable dust outputs back to the wallet to make them easier to spend and mix.
|
||||
*
|
||||
* @param doNotRelay specifies if the resulting transaction should not be relayed (defaults to false i.e. relayed)
|
||||
* @param do_not_relay specifies if the resulting transaction should not be relayed (defaults to false i.e. relayed)
|
||||
* @return the resulting transactions from sweeping dust
|
||||
*/
|
||||
vector<shared_ptr<monero_tx_wallet>> sweep_dust(bool doNotRelay = false);
|
||||
vector<shared_ptr<monero_tx_wallet>> sweep_dust(bool do_not_relay = false);
|
||||
//
|
||||
// /**
|
||||
// * Relay a transaction previously created without relaying.
|
||||
@@ -948,10 +948,10 @@ namespace monero {
|
||||
/**
|
||||
* Get notes for multiple transactions.
|
||||
*
|
||||
* @param txIds identify the transactions to get notes for
|
||||
* @param tx_ids identify the transactions to get notes for
|
||||
* @preturns notes for the transactions
|
||||
*/
|
||||
vector<string> get_tx_notes(const vector<string>& txIds) const;
|
||||
vector<string> get_tx_notes(const vector<string>& tx_ids) const;
|
||||
|
||||
/**
|
||||
* Set a note for a specific transaction.
|
||||
@@ -964,10 +964,10 @@ namespace monero {
|
||||
/**
|
||||
* Set notes for multiple transactions.
|
||||
*
|
||||
* @param txIds specify the transactions to set notes for
|
||||
* @param tx_ids specify the transactions to set notes for
|
||||
* @param notes are the notes to set for the transactions
|
||||
*/
|
||||
void set_tx_notes(const vector<string>& txIds, const vector<string>& notes);
|
||||
void set_tx_notes(const vector<string>& tx_ids, const vector<string>& notes);
|
||||
|
||||
/**
|
||||
* Sign a message.
|
||||
@@ -1119,10 +1119,10 @@ namespace monero {
|
||||
// *
|
||||
// * @param address is the entry address
|
||||
// * @param description is the entry description (optional)
|
||||
// * @param paymentId is the entry paymet id (optional)
|
||||
// * @param payment_id is the entry paymet id (optional)
|
||||
// * @return the index of the added entry
|
||||
// */
|
||||
// public int addAddressBookEntry(string address, string description, string paymentId);
|
||||
// public int addAddressBookEntry(string address, string description, string payment_id);
|
||||
//
|
||||
// /**
|
||||
// * Delete an address book entry.
|
||||
@@ -1234,7 +1234,7 @@ namespace monero {
|
||||
boost::optional<MoneroWalletListener&> listener = boost::none; // wallet's external listener
|
||||
|
||||
void initCommon();
|
||||
vector<monero_subaddress> getSubaddressesAux(uint32_t accountIdx, const vector<uint32_t>& subaddressIndices, const vector<tools::wallet2::transfer_details>& transfers) const;
|
||||
vector<monero_subaddress> getSubaddressesAux(uint32_t accountIdx, const vector<uint32_t>& subaddress_indices, const vector<tools::wallet2::transfer_details>& transfers) const;
|
||||
|
||||
// blockchain sync management
|
||||
mutable std::atomic<bool> isSynced; // whether or not wallet is synced
|
||||
|
||||
+149
-149
@@ -65,9 +65,9 @@ namespace monero {
|
||||
|
||||
// ----------------------- UNDECLARED PRIVATE HELPERS -----------------------
|
||||
|
||||
void mergeIncomingTransfer(vector<shared_ptr<monero_incoming_transfer>>& transfers, const shared_ptr<monero_incoming_transfer>& transfer) {
|
||||
void merge_incoming_transfer(vector<shared_ptr<monero_incoming_transfer>>& transfers, const shared_ptr<monero_incoming_transfer>& transfer) {
|
||||
for (const shared_ptr<monero_incoming_transfer>& aTransfer : transfers) {
|
||||
if (aTransfer->accountIndex.get() == transfer->accountIndex.get() && aTransfer->subaddressIndex.get() == transfer->subaddressIndex.get()) {
|
||||
if (aTransfer->account_index.get() == transfer->account_index.get() && aTransfer->subaddress_index.get() == transfer->subaddress_index.get()) {
|
||||
aTransfer->merge(aTransfer, transfer);
|
||||
return;
|
||||
}
|
||||
@@ -80,9 +80,9 @@ namespace monero {
|
||||
boost::property_tree::ptree monero_account::to_property_tree() const {
|
||||
boost::property_tree::ptree node;
|
||||
if (index != boost::none) node.put("index", *index);
|
||||
if (primaryAddress != boost::none) node.put("primaryAddress", *primaryAddress);
|
||||
if (primary_address != boost::none) node.put("primary_address", *primary_address);
|
||||
if (balance != boost::none) node.put("balance", *balance);
|
||||
if (unlockedBalance != boost::none) node.put("unlockedBalance", *unlockedBalance);
|
||||
if (unlocked_balance != boost::none) node.put("unlocked_balance", *unlocked_balance);
|
||||
if (!subaddresses.empty()) node.add_child("subaddresses", monero_utils::to_property_tree(subaddresses));
|
||||
return node;
|
||||
}
|
||||
@@ -91,15 +91,15 @@ namespace monero {
|
||||
|
||||
boost::property_tree::ptree monero_subaddress::to_property_tree() const {
|
||||
boost::property_tree::ptree node;
|
||||
if (accountIndex != boost::none) node.put("accountIndex", *accountIndex);
|
||||
if (account_index != boost::none) node.put("account_index", *account_index);
|
||||
if (index != boost::none) node.put("index", *index);
|
||||
if (address != boost::none) node.put("address", *address);
|
||||
if (label != boost::none) node.put("label", *label);
|
||||
if (balance != boost::none) node.put("balance", *balance);
|
||||
if (unlockedBalance != boost::none) node.put("unlockedBalance", *unlockedBalance);
|
||||
if (numUnspentOutputs != boost::none) node.put("numUnspentOutputs", *numUnspentOutputs);
|
||||
if (isUsed != boost::none) node.put("isUsed", *isUsed);
|
||||
if (numBlocksToUnlock != boost::none) node.put("numBlocksToUnlock", *numBlocksToUnlock);
|
||||
if (unlocked_balance != boost::none) node.put("unlocked_balance", *unlocked_balance);
|
||||
if (num_unspent_outputs != boost::none) node.put("num_unspent_outputs", *num_unspent_outputs);
|
||||
if (is_used != boost::none) node.put("is_used", *is_used);
|
||||
if (num_blocks_to_unlock != boost::none) node.put("num_blocks_to_unlock", *num_blocks_to_unlock);
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -118,18 +118,18 @@ namespace monero {
|
||||
monero_tx::copy(static_pointer_cast<monero_tx>(src), static_pointer_cast<monero_tx>(tgt));
|
||||
|
||||
// copy wallet extensions
|
||||
if (!src->incomingTransfers.empty()) {
|
||||
tgt->incomingTransfers = vector<shared_ptr<monero_incoming_transfer>>();
|
||||
for (const shared_ptr<monero_incoming_transfer>& transfer : src->incomingTransfers) {
|
||||
if (!src->incoming_transfers.empty()) {
|
||||
tgt->incoming_transfers = vector<shared_ptr<monero_incoming_transfer>>();
|
||||
for (const shared_ptr<monero_incoming_transfer>& transfer : src->incoming_transfers) {
|
||||
shared_ptr<monero_incoming_transfer> transferCopy = transfer->copy(transfer, make_shared<monero_incoming_transfer>());
|
||||
transferCopy->tx = tgt;
|
||||
tgt->incomingTransfers.push_back(transferCopy);
|
||||
tgt->incoming_transfers.push_back(transferCopy);
|
||||
}
|
||||
}
|
||||
if (src->outgoingTransfer != boost::none) {
|
||||
shared_ptr<monero_outgoing_transfer> transferCopy = src->outgoingTransfer.get()->copy(src->outgoingTransfer.get(), make_shared<monero_outgoing_transfer>());
|
||||
if (src->outgoing_transfer != boost::none) {
|
||||
shared_ptr<monero_outgoing_transfer> transferCopy = src->outgoing_transfer.get()->copy(src->outgoing_transfer.get(), make_shared<monero_outgoing_transfer>());
|
||||
transferCopy->tx = tgt;
|
||||
tgt->outgoingTransfer = transferCopy;
|
||||
tgt->outgoing_transfer = transferCopy;
|
||||
}
|
||||
tgt->note = src->note;
|
||||
|
||||
@@ -138,18 +138,18 @@ namespace monero {
|
||||
|
||||
boost::property_tree::ptree monero_tx_wallet::to_property_tree() const {
|
||||
boost::property_tree::ptree node = monero_tx::to_property_tree();
|
||||
if (!incomingTransfers.empty()) node.add_child("incomingTransfers", monero_utils::to_property_tree(incomingTransfers));
|
||||
if (outgoingTransfer != boost::none) node.add_child("outgoingTransfer", (*outgoingTransfer)->to_property_tree());
|
||||
if (!incoming_transfers.empty()) node.add_child("incoming_transfers", monero_utils::to_property_tree(incoming_transfers));
|
||||
if (outgoing_transfer != boost::none) node.add_child("outgoing_transfer", (*outgoing_transfer)->to_property_tree());
|
||||
if (note != boost::none) node.put("note", *note);
|
||||
return node;
|
||||
}
|
||||
|
||||
bool monero_tx_wallet::getIsOutgoing() const {
|
||||
return outgoingTransfer != boost::none;
|
||||
return outgoing_transfer != boost::none;
|
||||
}
|
||||
|
||||
bool monero_tx_wallet::getIsIncoming() const {
|
||||
return !incomingTransfers.empty();
|
||||
return !incoming_transfers.empty();
|
||||
}
|
||||
|
||||
void monero_tx_wallet::merge(const shared_ptr<monero_tx>& self, const shared_ptr<monero_tx>& other) {
|
||||
@@ -167,18 +167,18 @@ namespace monero {
|
||||
note = monero_utils::reconcile(note, other->note);
|
||||
|
||||
// merge incoming transfers
|
||||
if (!other->incomingTransfers.empty()) {
|
||||
for (const shared_ptr<monero_incoming_transfer>& transfer : other->incomingTransfers) { // NOTE: not using reference so shared_ptr is not deleted when tx is dereferenced
|
||||
if (!other->incoming_transfers.empty()) {
|
||||
for (const shared_ptr<monero_incoming_transfer>& transfer : other->incoming_transfers) { // NOTE: not using reference so shared_ptr is not deleted when tx is dereferenced
|
||||
transfer->tx = self;
|
||||
mergeIncomingTransfer(self->incomingTransfers, transfer);
|
||||
merge_incoming_transfer(self->incoming_transfers, transfer);
|
||||
}
|
||||
}
|
||||
|
||||
// merge outgoing transfer
|
||||
if (other->outgoingTransfer != boost::none) {
|
||||
other->outgoingTransfer.get()->tx = self;
|
||||
if (self->outgoingTransfer == boost::none) self->outgoingTransfer = other->outgoingTransfer;
|
||||
else self->outgoingTransfer.get()->merge(self->outgoingTransfer.get(), other->outgoingTransfer.get());
|
||||
if (other->outgoing_transfer != boost::none) {
|
||||
other->outgoing_transfer.get()->tx = self;
|
||||
if (self->outgoing_transfer == boost::none) self->outgoing_transfer = other->outgoing_transfer;
|
||||
else self->outgoing_transfer.get()->merge(self->outgoing_transfer.get(), other->outgoing_transfer.get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,32 +200,32 @@ namespace monero {
|
||||
monero_tx_wallet::copy(static_pointer_cast<monero_tx>(src), static_pointer_cast<monero_tx>(tgt));
|
||||
|
||||
// copy request extensions
|
||||
tgt->isOutgoing = src->isOutgoing;
|
||||
tgt->isIncoming = src->isIncoming;
|
||||
if (!src->txIds.empty()) tgt->txIds = vector<string>(src->txIds);
|
||||
tgt-> hasPaymentId = src->hasPaymentId;
|
||||
if (!src->paymentIds.empty()) tgt->paymentIds = vector<string>(src->paymentIds);
|
||||
tgt->is_outgoing = src->is_outgoing;
|
||||
tgt->is_incoming = src->is_incoming;
|
||||
if (!src->tx_ids.empty()) tgt->tx_ids = vector<string>(src->tx_ids);
|
||||
tgt-> has_payment_id = src->has_payment_id;
|
||||
if (!src->payment_ids.empty()) tgt->payment_ids = vector<string>(src->payment_ids);
|
||||
tgt->height = src->height;
|
||||
tgt->minHeight = src->minHeight;
|
||||
tgt->maxHeight = src->maxHeight;
|
||||
tgt->includeOutputs = src->includeOutputs;
|
||||
if (src->transferRequest != boost::none) tgt->transferRequest = src->transferRequest.get()->copy(src->transferRequest.get(), make_shared<monero_transfer_request>());
|
||||
if (src->outputRequest != boost::none) tgt->outputRequest = src->outputRequest.get()->copy(src->outputRequest.get(), make_shared<monero_output_request>());
|
||||
tgt->min_height = src->min_height;
|
||||
tgt->max_height = src->max_height;
|
||||
tgt->include_outputs = src->include_outputs;
|
||||
if (src->transfer_request != boost::none) tgt->transfer_request = src->transfer_request.get()->copy(src->transfer_request.get(), make_shared<monero_transfer_request>());
|
||||
if (src->output_request != boost::none) tgt->output_request = src->output_request.get()->copy(src->output_request.get(), make_shared<monero_output_request>());
|
||||
return tgt;
|
||||
};
|
||||
|
||||
boost::property_tree::ptree monero_tx_request::to_property_tree() const {
|
||||
boost::property_tree::ptree node = monero_tx_wallet::to_property_tree();
|
||||
if (isOutgoing != boost::none) node.put("isOutgoing", *isOutgoing);
|
||||
if (isIncoming != boost::none) node.put("isIncoming", *isIncoming);
|
||||
if (!txIds.empty()) node.add_child("txIds", monero_utils::to_property_tree(txIds));
|
||||
if (hasPaymentId != boost::none) node.put("hasPaymentId", *hasPaymentId);
|
||||
if (!paymentIds.empty()) node.add_child("paymentIds", monero_utils::to_property_tree(paymentIds));
|
||||
if (is_outgoing != boost::none) node.put("is_outgoing", *is_outgoing);
|
||||
if (is_incoming != boost::none) node.put("is_incoming", *is_incoming);
|
||||
if (!tx_ids.empty()) node.add_child("tx_ids", monero_utils::to_property_tree(tx_ids));
|
||||
if (has_payment_id != boost::none) node.put("has_payment_id", *has_payment_id);
|
||||
if (!payment_ids.empty()) node.add_child("payment_ids", monero_utils::to_property_tree(payment_ids));
|
||||
if (height != boost::none) node.put("height", *height);
|
||||
if (minHeight != boost::none) node.put("minHeight", *minHeight);
|
||||
if (maxHeight != boost::none) node.put("maxHeight", *maxHeight);
|
||||
if (includeOutputs != boost::none) node.put("includeOutputs", *includeOutputs);
|
||||
if (transferRequest != boost::none) node.add_child("transferRequest", (*transferRequest)->to_property_tree());
|
||||
if (min_height != boost::none) node.put("min_height", *min_height);
|
||||
if (max_height != boost::none) node.put("max_height", *max_height);
|
||||
if (include_outputs != boost::none) node.put("include_outputs", *include_outputs);
|
||||
if (transfer_request != boost::none) node.add_child("transfer_request", (*transfer_request)->to_property_tree());
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -234,20 +234,20 @@ namespace monero {
|
||||
|
||||
// filter on tx
|
||||
if (id != boost::none && id != tx->id) return false;
|
||||
if (paymentId != boost::none && paymentId != tx->paymentId) return false;
|
||||
if (isConfirmed != boost::none && isConfirmed != tx->isConfirmed) return false;
|
||||
if (inTxPool != boost::none && inTxPool != tx->inTxPool) return false;
|
||||
if (doNotRelay != boost::none && doNotRelay != tx->doNotRelay) return false;
|
||||
if (isFailed != boost::none && isFailed != tx->isFailed) return false;
|
||||
if (isMinerTx != boost::none && isMinerTx != tx->isMinerTx) return false;
|
||||
if (payment_id != boost::none && payment_id != tx->payment_id) return false;
|
||||
if (is_confirmed != boost::none && is_confirmed != tx->is_confirmed) return false;
|
||||
if (in_tx_pool != boost::none && in_tx_pool != tx->in_tx_pool) return false;
|
||||
if (do_not_relay != boost::none && do_not_relay != tx->do_not_relay) return false;
|
||||
if (is_failed != boost::none && is_failed != tx->is_failed) return false;
|
||||
if (is_miner_tx != boost::none && is_miner_tx != tx->is_miner_tx) return false;
|
||||
|
||||
// at least one transfer must meet transfer request if defined
|
||||
if (transferRequest != boost::none) {
|
||||
if (transfer_request != boost::none) {
|
||||
bool matchFound = false;
|
||||
if (tx->outgoingTransfer != boost::none && (*transferRequest)->meetsCriteria((*tx->outgoingTransfer).get())) matchFound = true;
|
||||
else if (!tx->incomingTransfers.empty()) {
|
||||
for (const shared_ptr<monero_incoming_transfer>& incomingTransfer : tx->incomingTransfers) {
|
||||
if ((*transferRequest)->meetsCriteria(incomingTransfer.get())) {
|
||||
if (tx->outgoing_transfer != boost::none && (*transfer_request)->meetsCriteria((*tx->outgoing_transfer).get())) matchFound = true;
|
||||
else if (!tx->incoming_transfers.empty()) {
|
||||
for (const shared_ptr<monero_incoming_transfer>& incomingTransfer : tx->incoming_transfers) {
|
||||
if ((*transfer_request)->meetsCriteria(incomingTransfer.get())) {
|
||||
matchFound = true;
|
||||
break;
|
||||
}
|
||||
@@ -257,24 +257,24 @@ namespace monero {
|
||||
}
|
||||
|
||||
// filter on having a payment id
|
||||
if (hasPaymentId != boost::none) {
|
||||
if (*hasPaymentId && tx->paymentId == boost::none) return false;
|
||||
if (!*hasPaymentId && tx->paymentId != boost::none) return false;
|
||||
if (has_payment_id != boost::none) {
|
||||
if (*has_payment_id && tx->payment_id == boost::none) return false;
|
||||
if (!*has_payment_id && tx->payment_id != boost::none) return false;
|
||||
}
|
||||
|
||||
// filter on incoming
|
||||
if (isIncoming != boost::none && isIncoming != tx->getIsIncoming()) return false;
|
||||
if (is_incoming != boost::none && is_incoming != tx->getIsIncoming()) return false;
|
||||
|
||||
// filter on outgoing
|
||||
if (isOutgoing != boost::none && isOutgoing != tx->getIsOutgoing()) return false;
|
||||
if (is_outgoing != boost::none && is_outgoing != tx->getIsOutgoing()) return false;
|
||||
|
||||
// filter on remaining fields
|
||||
boost::optional<uint64_t> txHeight = tx->get_height();
|
||||
if (!txIds.empty() && find(txIds.begin(), txIds.end(), *tx->id) == txIds.end()) return false;
|
||||
if (!paymentIds.empty() && (tx->paymentId == boost::none || find(paymentIds.begin(), paymentIds.end(), *tx->paymentId) == paymentIds.end())) return false;
|
||||
if (!tx_ids.empty() && find(tx_ids.begin(), tx_ids.end(), *tx->id) == tx_ids.end()) return false;
|
||||
if (!payment_ids.empty() && (tx->payment_id == boost::none || find(payment_ids.begin(), payment_ids.end(), *tx->payment_id) == payment_ids.end())) return false;
|
||||
if (height != boost::none && (txHeight == boost::none || *txHeight != *height)) return false;
|
||||
if (minHeight != boost::none && (txHeight == boost::none || *txHeight < *minHeight)) return false;
|
||||
if (maxHeight != boost::none && (txHeight == boost::none || *txHeight > *maxHeight)) return false;
|
||||
if (min_height != boost::none && (txHeight == boost::none || *txHeight < *min_height)) return false;
|
||||
if (max_height != boost::none && (txHeight == boost::none || *txHeight > *max_height)) return false;
|
||||
|
||||
// transaction meets request criteria
|
||||
return true;
|
||||
@@ -303,16 +303,16 @@ namespace monero {
|
||||
MTRACE("monero_transfer::copy(const shared_ptr<monero_transfer>& src, const shared_ptr<monero_transfer>& tgt)");
|
||||
tgt->tx = src->tx; // reference parent tx by default
|
||||
tgt->amount = src->amount;
|
||||
tgt->accountIndex = src->accountIndex;
|
||||
tgt->numSuggestedConfirmations = src->numSuggestedConfirmations;
|
||||
tgt->account_index = src->account_index;
|
||||
tgt->num_suggested_confirmations = src->num_suggested_confirmations;
|
||||
return tgt;
|
||||
}
|
||||
|
||||
boost::property_tree::ptree monero_transfer::to_property_tree() const {
|
||||
boost::property_tree::ptree node;
|
||||
if (amount != boost::none) node.put("amount", *amount);
|
||||
if (accountIndex != boost::none) node.put("accountIndex", *accountIndex);
|
||||
if (numSuggestedConfirmations != boost::none) node.put("numSuggestedConfirmations", *numSuggestedConfirmations);
|
||||
if (account_index != boost::none) node.put("account_index", *account_index);
|
||||
if (num_suggested_confirmations != boost::none) node.put("num_suggested_confirmations", *num_suggested_confirmations);
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -327,16 +327,16 @@ namespace monero {
|
||||
}
|
||||
|
||||
// otherwise merge transfer fields
|
||||
accountIndex = monero_utils::reconcile(accountIndex, other->accountIndex, "acountIndex");
|
||||
account_index = monero_utils::reconcile(account_index, other->account_index, "acountIndex");
|
||||
|
||||
// TODO monero core: failed tx in pool (after testUpdateLockedDifferentAccounts()) causes non-originating saved wallets to return duplicate incoming transfers but one has amount/numSuggestedConfirmations of 0
|
||||
// TODO monero core: failed tx in pool (after testUpdateLockedDifferentAccounts()) causes non-originating saved wallets to return duplicate incoming transfers but one has amount/num_suggested_confirmations of 0
|
||||
if (amount != boost::none && other->amount != boost::none && *amount != *other->amount && (*amount == 0 || *other->amount == 0)) {
|
||||
accountIndex = monero_utils::reconcile(accountIndex, other->accountIndex, boost::none, boost::none, true, "acountIndex");
|
||||
numSuggestedConfirmations = monero_utils::reconcile(numSuggestedConfirmations, other->numSuggestedConfirmations, boost::none, boost::none, true, "numSuggestedConfirmations");
|
||||
MWARNING("WARNING: failed tx in pool causes non-originating wallets to return duplicate incoming transfers but with one amount/numSuggestedConfirmations of 0");
|
||||
account_index = monero_utils::reconcile(account_index, other->account_index, boost::none, boost::none, true, "acountIndex");
|
||||
num_suggested_confirmations = monero_utils::reconcile(num_suggested_confirmations, other->num_suggested_confirmations, boost::none, boost::none, true, "num_suggested_confirmations");
|
||||
MWARNING("WARNING: failed tx in pool causes non-originating wallets to return duplicate incoming transfers but with one amount/num_suggested_confirmations of 0");
|
||||
} else {
|
||||
amount = monero_utils::reconcile(amount, other->amount, "transfer amount");
|
||||
numSuggestedConfirmations = monero_utils::reconcile(numSuggestedConfirmations, other->numSuggestedConfirmations, boost::none, boost::none, false, "numSuggestedConfirmations");
|
||||
num_suggested_confirmations = monero_utils::reconcile(num_suggested_confirmations, other->num_suggested_confirmations, boost::none, boost::none, false, "num_suggested_confirmations");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -357,7 +357,7 @@ namespace monero {
|
||||
|
||||
boost::property_tree::ptree monero_incoming_transfer::to_property_tree() const {
|
||||
boost::property_tree::ptree node = monero_transfer::to_property_tree();
|
||||
if (subaddressIndex != boost::none) node.put("subaddressIndex", *subaddressIndex);
|
||||
if (subaddress_index != boost::none) node.put("subaddress_index", *subaddress_index);
|
||||
if (address != boost::none) node.put("address", *address);
|
||||
return node;
|
||||
}
|
||||
@@ -369,7 +369,7 @@ namespace monero {
|
||||
void monero_incoming_transfer::merge(const shared_ptr<monero_incoming_transfer>& self, const shared_ptr<monero_incoming_transfer>& other) {
|
||||
if (self == other) return;
|
||||
monero_transfer::merge(self, other);
|
||||
subaddressIndex = monero_utils::reconcile(subaddressIndex, other->subaddressIndex, "incoming transfer subaddressIndex");
|
||||
subaddress_index = monero_utils::reconcile(subaddress_index, other->subaddress_index, "incoming transfer subaddress_index");
|
||||
address = monero_utils::reconcile(address, other->address);
|
||||
}
|
||||
|
||||
@@ -387,7 +387,7 @@ namespace monero {
|
||||
|
||||
boost::property_tree::ptree monero_outgoing_transfer::to_property_tree() const {
|
||||
boost::property_tree::ptree node = monero_transfer::to_property_tree();
|
||||
if (!subaddressIndices.empty()) node.add_child("subaddressIndices", monero_utils::to_property_tree(subaddressIndices));
|
||||
if (!subaddress_indices.empty()) node.add_child("subaddress_indices", monero_utils::to_property_tree(subaddress_indices));
|
||||
if (!addresses.empty()) node.add_child("addresses", monero_utils::to_property_tree(addresses));
|
||||
if (!destinations.empty()) node.add_child("destinations", monero_utils::to_property_tree(destinations));
|
||||
return node;
|
||||
@@ -400,7 +400,7 @@ namespace monero {
|
||||
void monero_outgoing_transfer::merge(const shared_ptr<monero_outgoing_transfer>& self, const shared_ptr<monero_outgoing_transfer>& other) {
|
||||
if (self == other) return;
|
||||
monero_transfer::merge(self, other);
|
||||
subaddressIndices = monero_utils::reconcile(subaddressIndices, other->subaddressIndices);
|
||||
subaddress_indices = monero_utils::reconcile(subaddress_indices, other->subaddress_indices);
|
||||
addresses = monero_utils::reconcile(addresses, other->addresses);
|
||||
destinations = monero_utils::reconcile(destinations, other->destinations);
|
||||
}
|
||||
@@ -419,30 +419,30 @@ namespace monero {
|
||||
monero_transfer::copy(static_pointer_cast<monero_transfer>(src), static_pointer_cast<monero_transfer>(tgt));
|
||||
|
||||
// copy extensions
|
||||
tgt->isIncoming = src->isIncoming;
|
||||
tgt->is_incoming = src->is_incoming;
|
||||
tgt->address = src->address;
|
||||
if (!src->addresses.empty()) tgt->addresses = vector<string>(src->addresses);
|
||||
tgt->subaddressIndex = src->subaddressIndex;
|
||||
if (!src->subaddressIndices.empty()) tgt->subaddressIndices = vector<uint32_t>(src->subaddressIndices);
|
||||
tgt->subaddress_index = src->subaddress_index;
|
||||
if (!src->subaddress_indices.empty()) tgt->subaddress_indices = vector<uint32_t>(src->subaddress_indices);
|
||||
if (!src->destinations.empty()) {
|
||||
for (const shared_ptr<monero_destination>& destination : src->destinations) {
|
||||
tgt->destinations.push_back(destination->copy(destination, make_shared<monero_destination>()));
|
||||
}
|
||||
}
|
||||
tgt->hasDestinations = src->hasDestinations;
|
||||
tgt->txRequest = src->txRequest;
|
||||
tgt->has_destinations = src->has_destinations;
|
||||
tgt->tx_request = src->tx_request;
|
||||
return tgt;
|
||||
};
|
||||
|
||||
boost::optional<bool> monero_transfer_request::getIsIncoming() const { return isIncoming; }
|
||||
boost::optional<bool> monero_transfer_request::getIsIncoming() const { return is_incoming; }
|
||||
|
||||
boost::property_tree::ptree monero_transfer_request::to_property_tree() const {
|
||||
boost::property_tree::ptree node = monero_transfer::to_property_tree();
|
||||
if (getIsIncoming() != boost::none) node.put("isIncoming", *getIsIncoming());
|
||||
if (getIsIncoming() != boost::none) node.put("is_incoming", *getIsIncoming());
|
||||
if (address != boost::none) node.put("address", *address);
|
||||
if (subaddressIndex != boost::none) node.put("subaddressIndex", *subaddressIndex);
|
||||
if (hasDestinations != boost::none) node.put("hasDestinations", *hasDestinations);
|
||||
if (!subaddressIndices.empty()) node.add_child("subaddressIndices", monero_utils::to_property_tree(subaddressIndices));
|
||||
if (subaddress_index != boost::none) node.put("subaddress_index", *subaddress_index);
|
||||
if (has_destinations != boost::none) node.put("has_destinations", *has_destinations);
|
||||
if (!subaddress_indices.empty()) node.add_child("subaddress_indices", monero_utils::to_property_tree(subaddress_indices));
|
||||
if (!addresses.empty()) node.add_child("addresses", monero_utils::to_property_tree(addresses));
|
||||
if (!destinations.empty()) node.add_child("destinations", monero_utils::to_property_tree(destinations));
|
||||
return node;
|
||||
@@ -450,22 +450,22 @@ namespace monero {
|
||||
|
||||
bool monero_transfer_request::meetsCriteria(monero_transfer* transfer) const {
|
||||
if (transfer == nullptr) throw runtime_error("transfer is null");
|
||||
if (txRequest != boost::none && (*txRequest)->transferRequest != boost::none) throw runtime_error("Transfer request's tx request cannot have a circular transfer request"); // TODO: could auto detect and handle this. port to java/js
|
||||
if (tx_request != boost::none && (*tx_request)->transfer_request != boost::none) throw runtime_error("Transfer request's tx request cannot have a circular transfer request"); // TODO: could auto detect and handle this. port to java/js
|
||||
|
||||
// filter on common fields
|
||||
if (getIsIncoming() != boost::none && *getIsIncoming() != *transfer->getIsIncoming()) return false;
|
||||
if (getIsOutgoing() != boost::none && getIsOutgoing() != transfer->getIsOutgoing()) return false;
|
||||
if (amount != boost::none && *amount != *transfer->amount) return false;
|
||||
if (accountIndex != boost::none && *accountIndex != *transfer->accountIndex) return false;
|
||||
if (account_index != boost::none && *account_index != *transfer->account_index) return false;
|
||||
|
||||
// filter on incoming fields
|
||||
monero_incoming_transfer* inTransfer = dynamic_cast<monero_incoming_transfer*>(transfer);
|
||||
if (inTransfer != nullptr) {
|
||||
if (hasDestinations != boost::none) return false;
|
||||
if (has_destinations != boost::none) return false;
|
||||
if (address != boost::none && *address != *inTransfer->address) return false;
|
||||
if (!addresses.empty() && find(addresses.begin(), addresses.end(), *inTransfer->address) == addresses.end()) return false;
|
||||
if (subaddressIndex != boost::none && *subaddressIndex != *inTransfer->subaddressIndex) return false;
|
||||
if (!subaddressIndices.empty() && find(subaddressIndices.begin(), subaddressIndices.end(), *inTransfer->subaddressIndex) == subaddressIndices.end()) return false;
|
||||
if (subaddress_index != boost::none && *subaddress_index != *inTransfer->subaddress_index) return false;
|
||||
if (!subaddress_indices.empty() && find(subaddress_indices.begin(), subaddress_indices.end(), *inTransfer->subaddress_index) == subaddress_indices.end()) return false;
|
||||
}
|
||||
|
||||
// filter on outgoing fields
|
||||
@@ -488,12 +488,12 @@ namespace monero {
|
||||
}
|
||||
|
||||
// filter on subaddress indices
|
||||
if (subaddressIndex != boost::none && (outTransfer->subaddressIndices.empty() || find(outTransfer->subaddressIndices.begin(), outTransfer->subaddressIndices.end(), *subaddressIndex) == outTransfer->subaddressIndices.end())) return false; // TODO: will filter all transfers if they don't contain subaddress indices
|
||||
if (!subaddressIndices.empty()) {
|
||||
if (subaddress_index != boost::none && (outTransfer->subaddress_indices.empty() || find(outTransfer->subaddress_indices.begin(), outTransfer->subaddress_indices.end(), *subaddress_index) == outTransfer->subaddress_indices.end())) return false; // TODO: will filter all transfers if they don't contain subaddress indices
|
||||
if (!subaddress_indices.empty()) {
|
||||
bool intersects = false;
|
||||
for (const uint32_t& subaddressIndexReq : subaddressIndices) {
|
||||
for (const uint32_t& subaddressIndex : outTransfer->subaddressIndices) {
|
||||
if (subaddressIndexReq == subaddressIndex) {
|
||||
for (const uint32_t& subaddressIndexReq : subaddress_indices) {
|
||||
for (const uint32_t& subaddress_index : outTransfer->subaddress_indices) {
|
||||
if (subaddressIndexReq == subaddress_index) {
|
||||
intersects = true;
|
||||
break;
|
||||
}
|
||||
@@ -503,9 +503,9 @@ namespace monero {
|
||||
}
|
||||
|
||||
// filter on having destinations
|
||||
if (hasDestinations != boost::none) {
|
||||
if (*hasDestinations && outTransfer->destinations.empty()) return false;
|
||||
if (!*hasDestinations && !outTransfer->destinations.empty()) return false;
|
||||
if (has_destinations != boost::none) {
|
||||
if (*has_destinations && outTransfer->destinations.empty()) return false;
|
||||
if (!*has_destinations && !outTransfer->destinations.empty()) return false;
|
||||
}
|
||||
|
||||
// filter on destinations TODO: start with test for this
|
||||
@@ -516,7 +516,7 @@ namespace monero {
|
||||
if (inTransfer == nullptr && outTransfer == nullptr) throw runtime_error("Transfer must be monero_incoming_transfer or monero_outgoing_transfer");
|
||||
|
||||
// filter with tx request
|
||||
if (txRequest != boost::none && !(*txRequest)->meetsCriteria(transfer->tx.get())) return false;
|
||||
if (tx_request != boost::none && !(*tx_request)->meetsCriteria(transfer->tx.get())) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -528,28 +528,28 @@ namespace monero {
|
||||
};
|
||||
|
||||
shared_ptr<monero_output_wallet> monero_output_wallet::copy(const shared_ptr<monero_output_wallet>& src, const shared_ptr<monero_output_wallet>& tgt) const {
|
||||
MTRACE("monero_output_wallet::copy(outputWallet)");
|
||||
MTRACE("monero_output_wallet::copy(output_wallet)");
|
||||
if (this != src.get()) throw runtime_error("this != src");
|
||||
|
||||
// copy base class
|
||||
monero_output::copy(static_pointer_cast<monero_output>(src), static_pointer_cast<monero_output>(tgt));
|
||||
|
||||
// copy extensions
|
||||
tgt->accountIndex = src->accountIndex;
|
||||
tgt->subaddressIndex = src->subaddressIndex;
|
||||
tgt->isSpent = src->isSpent;
|
||||
tgt->isUnlocked = src->isUnlocked;
|
||||
tgt->isFrozen = src->isFrozen;
|
||||
tgt->account_index = src->account_index;
|
||||
tgt->subaddress_index = src->subaddress_index;
|
||||
tgt->is_spent = src->is_spent;
|
||||
tgt->is_unlocked = src->is_unlocked;
|
||||
tgt->is_frozen = src->is_frozen;
|
||||
return tgt;
|
||||
};
|
||||
|
||||
boost::property_tree::ptree monero_output_wallet::to_property_tree() const {
|
||||
boost::property_tree::ptree node = monero_output::to_property_tree();
|
||||
if (accountIndex != boost::none) node.put("accountIndex", *accountIndex);
|
||||
if (subaddressIndex != boost::none) node.put("subaddressIndex", *subaddressIndex);
|
||||
if (isSpent != boost::none) node.put("isSpent", *isSpent);
|
||||
if (isUnlocked != boost::none) node.put("isUnlocked", *isUnlocked);
|
||||
if (isFrozen != boost::none) node.put("isFrozen", *isFrozen);
|
||||
if (account_index != boost::none) node.put("account_index", *account_index);
|
||||
if (subaddress_index != boost::none) node.put("subaddress_index", *subaddress_index);
|
||||
if (is_spent != boost::none) node.put("is_spent", *is_spent);
|
||||
if (is_unlocked != boost::none) node.put("is_unlocked", *is_unlocked);
|
||||
if (is_frozen != boost::none) node.put("is_frozen", *is_frozen);
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -572,44 +572,44 @@ namespace monero {
|
||||
};
|
||||
|
||||
shared_ptr<monero_output_request> monero_output_request::copy(const shared_ptr<monero_output_request>& src, const shared_ptr<monero_output_request>& tgt) const {
|
||||
MTRACE("monero_output_request::copy(outputRequest)");
|
||||
MTRACE("monero_output_request::copy(output_request)");
|
||||
if (this != src.get()) throw runtime_error("this != src");
|
||||
|
||||
// copy base class
|
||||
monero_output_wallet::copy(static_pointer_cast<monero_output>(src), static_pointer_cast<monero_output>(tgt));
|
||||
|
||||
// copy extensions
|
||||
if (!src->subaddressIndices.empty()) tgt->subaddressIndices = vector<uint32_t>(src->subaddressIndices);
|
||||
if (!src->subaddress_indices.empty()) tgt->subaddress_indices = vector<uint32_t>(src->subaddress_indices);
|
||||
return tgt;
|
||||
};
|
||||
|
||||
boost::property_tree::ptree monero_output_request::to_property_tree() const {
|
||||
boost::property_tree::ptree node = monero_output_wallet::to_property_tree();
|
||||
if (!subaddressIndices.empty()) node.add_child("subaddressIndices", monero_utils::to_property_tree(subaddressIndices));
|
||||
if (!subaddress_indices.empty()) node.add_child("subaddress_indices", monero_utils::to_property_tree(subaddress_indices));
|
||||
return node;
|
||||
}
|
||||
|
||||
bool monero_output_request::meetsCriteria(monero_output_wallet* output) const {
|
||||
|
||||
// filter on output
|
||||
if (accountIndex != boost::none && *accountIndex != *output->accountIndex) return false;
|
||||
if (subaddressIndex != boost::none && *subaddressIndex != *output->subaddressIndex) return false;
|
||||
if (account_index != boost::none && *account_index != *output->account_index) return false;
|
||||
if (subaddress_index != boost::none && *subaddress_index != *output->subaddress_index) return false;
|
||||
if (amount != boost::none && *amount != *output->amount) return false;
|
||||
if (isSpent != boost::none && *isSpent != *output->isSpent) return false;
|
||||
if (isUnlocked != boost::none && *isUnlocked != *output->isUnlocked) return false;
|
||||
if (is_spent != boost::none && *is_spent != *output->is_spent) return false;
|
||||
if (is_unlocked != boost::none && *is_unlocked != *output->is_unlocked) return false;
|
||||
|
||||
// filter on output key image
|
||||
if (keyImage != boost::none) {
|
||||
if (output->keyImage == boost::none) return false;
|
||||
if ((*keyImage)->hex != boost::none && ((*output->keyImage)->hex == boost::none || *(*keyImage)->hex != *(*output->keyImage)->hex)) return false;
|
||||
if ((*keyImage)->signature != boost::none && ((*output->keyImage)->signature == boost::none || *(*keyImage)->signature != *(*output->keyImage)->signature)) return false;
|
||||
if (key_image != boost::none) {
|
||||
if (output->key_image == boost::none) return false;
|
||||
if ((*key_image)->hex != boost::none && ((*output->key_image)->hex == boost::none || *(*key_image)->hex != *(*output->key_image)->hex)) return false;
|
||||
if ((*key_image)->signature != boost::none && ((*output->key_image)->signature == boost::none || *(*key_image)->signature != *(*output->key_image)->signature)) return false;
|
||||
}
|
||||
|
||||
// filter on extensions
|
||||
if (!subaddressIndices.empty() && find(subaddressIndices.begin(), subaddressIndices.end(), *output->subaddressIndex) == subaddressIndices.end()) return false;
|
||||
if (!subaddress_indices.empty() && find(subaddress_indices.begin(), subaddress_indices.end(), *output->subaddress_index) == subaddress_indices.end()) return false;
|
||||
|
||||
// filter with tx request
|
||||
if (txRequest != boost::none && !(*txRequest)->meetsCriteria(static_pointer_cast<monero_tx_wallet>(output->tx).get())) return false;
|
||||
if (tx_request != boost::none && !(*tx_request)->meetsCriteria(static_pointer_cast<monero_tx_wallet>(output->tx).get())) return false;
|
||||
|
||||
// output meets request
|
||||
return true;
|
||||
@@ -620,20 +620,20 @@ namespace monero {
|
||||
boost::property_tree::ptree monero_send_request::to_property_tree() const {
|
||||
boost::property_tree::ptree node;
|
||||
if (!destinations.empty()) node.add_child("destinations", monero_utils::to_property_tree(destinations));
|
||||
if (paymentId != boost::none) node.put("paymentId", *paymentId);
|
||||
if (payment_id != boost::none) node.put("payment_id", *payment_id);
|
||||
if (priority != boost::none) node.put("priority", *priority);
|
||||
if (mixin != boost::none) node.put("mixin", *mixin);
|
||||
if (ringSize != boost::none) node.put("ringSize", *ringSize);
|
||||
if (accountIndex != boost::none) node.put("accountIndex", *accountIndex);
|
||||
if (!subaddressIndices.empty()) node.add_child("subaddressIndices", monero_utils::to_property_tree(subaddressIndices));
|
||||
if (unlockTime != boost::none) node.put("unlockTime", *unlockTime);
|
||||
if (canSplit != boost::none) node.put("canSplit", *canSplit);
|
||||
if (doNotRelay != boost::none) node.put("doNotRelay", *doNotRelay);
|
||||
if (account_index != boost::none) node.put("account_index", *account_index);
|
||||
if (!subaddress_indices.empty()) node.add_child("subaddress_indices", monero_utils::to_property_tree(subaddress_indices));
|
||||
if (unlock_time != boost::none) node.put("unlock_time", *unlock_time);
|
||||
if (can_split != boost::none) node.put("can_split", *can_split);
|
||||
if (do_not_relay != boost::none) node.put("do_not_relay", *do_not_relay);
|
||||
if (note != boost::none) node.put("note", *note);
|
||||
if (recipientName != boost::none) node.put("recipientName", *recipientName);
|
||||
if (belowAmount != boost::none) node.put("belowAmount", *belowAmount);
|
||||
if (sweepEachSubaddress != boost::none) node.put("sweepEachSubaddress", *sweepEachSubaddress);
|
||||
if (keyImage != boost::none) node.put("keyImage", *keyImage);
|
||||
if (receipient_name != boost::none) node.put("receipient_name", *receipient_name);
|
||||
if (below_amount != boost::none) node.put("below_amount", *below_amount);
|
||||
if (sweep_each_subaddress != boost::none) node.put("sweep_each_subaddress", *sweep_each_subaddress);
|
||||
if (key_image != boost::none) node.put("key_image", *key_image);
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -641,9 +641,9 @@ namespace monero {
|
||||
|
||||
boost::property_tree::ptree monero_integrated_address::to_property_tree() const {
|
||||
boost::property_tree::ptree node;
|
||||
node.put("standardAddress", standardAddress);
|
||||
node.put("paymentId", paymentId);
|
||||
node.put("integratedAddress", integratedAddress);
|
||||
node.put("standard_address", standard_address);
|
||||
node.put("payment_id", payment_id);
|
||||
node.put("integrated_address", integrated_address);
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -652,8 +652,8 @@ namespace monero {
|
||||
boost::property_tree::ptree monero_key_image_import_result::to_property_tree() const {
|
||||
boost::property_tree::ptree node;
|
||||
if (height != boost::none) node.put("height", *height);
|
||||
if (spentAmount != boost::none) node.put("spentAmount", *spentAmount);
|
||||
if (unspentAmount != boost::none) node.put("unspentAmount", *unspentAmount);
|
||||
if (spent_amount != boost::none) node.put("spent_amount", *spent_amount);
|
||||
if (unspent_amount != boost::none) node.put("unspent_amount", *unspent_amount);
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -661,7 +661,7 @@ namespace monero {
|
||||
|
||||
boost::property_tree::ptree monero_check::to_property_tree() const {
|
||||
boost::property_tree::ptree node;
|
||||
node.put("isGood", isGood);
|
||||
node.put("is_good", is_good);
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -669,9 +669,9 @@ namespace monero {
|
||||
|
||||
boost::property_tree::ptree monero_check_tx::to_property_tree() const {
|
||||
boost::property_tree::ptree node = monero_check::to_property_tree();;
|
||||
if (inTxPool != boost::none) node.put("inTxPool", *inTxPool);
|
||||
if (numConfirmations != boost::none) node.put("numConfirmations", *numConfirmations);
|
||||
if (receivedAmount != boost::none) node.put("receivedAmount", *receivedAmount);
|
||||
if (in_tx_pool != boost::none) node.put("in_tx_pool", *in_tx_pool);
|
||||
if (num_confirmations != boost::none) node.put("num_confirmations", *num_confirmations);
|
||||
if (received_amount != boost::none) node.put("received_amount", *received_amount);
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -679,8 +679,8 @@ namespace monero {
|
||||
|
||||
boost::property_tree::ptree monero_check_reserve::to_property_tree() const {
|
||||
boost::property_tree::ptree node = monero_check::to_property_tree();
|
||||
if (totalAmount != boost::none) node.put("totalAmount", *totalAmount);
|
||||
if (unconfirmedSpentAmount != boost::none) node.put("unconfirmedSpentAmount", *unconfirmedSpentAmount);
|
||||
if (total_amount != boost::none) node.put("total_amount", *total_amount);
|
||||
if (unconfirmed_spent_amount != boost::none) node.put("unconfirmed_spent_amount", *unconfirmed_spent_amount);
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,35 +66,35 @@ namespace monero {
|
||||
* Models a result of syncing a wallet.
|
||||
*/
|
||||
struct monero_sync_result {
|
||||
uint64_t numBlocksFetched;
|
||||
bool receivedMoney;
|
||||
uint64_t num_blocks_fetched;
|
||||
bool received_money;
|
||||
monero_sync_result() {}
|
||||
monero_sync_result(const uint64_t numBlocksFetched, const bool receivedMoney) : numBlocksFetched(numBlocksFetched), receivedMoney(receivedMoney) {}
|
||||
monero_sync_result(const uint64_t num_blocks_fetched, const bool received_money) : num_blocks_fetched(num_blocks_fetched), received_money(received_money) {}
|
||||
};
|
||||
|
||||
/**
|
||||
* Models a Monero subaddress.
|
||||
*/
|
||||
struct monero_subaddress : public serializable_struct {
|
||||
boost::optional<uint32_t> accountIndex;
|
||||
boost::optional<uint32_t> account_index;
|
||||
boost::optional<uint32_t> index;
|
||||
boost::optional<string> address;
|
||||
boost::optional<string> label;
|
||||
boost::optional<uint64_t> balance;
|
||||
boost::optional<uint64_t> unlockedBalance;
|
||||
boost::optional<uint32_t> numUnspentOutputs;
|
||||
boost::optional<bool> isUsed;
|
||||
boost::optional<uint32_t> numBlocksToUnlock;
|
||||
boost::optional<uint64_t> unlocked_balance;
|
||||
boost::optional<uint32_t> num_unspent_outputs;
|
||||
boost::optional<bool> is_used;
|
||||
boost::optional<uint32_t> num_blocks_to_unlock;
|
||||
// BEGIN_KV_SERIALIZE_MAP()
|
||||
// KV_SERIALIZE(accountIndex)
|
||||
// KV_SERIALIZE(account_index)
|
||||
// KV_SERIALIZE(index)
|
||||
// KV_SERIALIZE(address)
|
||||
// KV_SERIALIZE(label)
|
||||
// KV_SERIALIZE(balance)
|
||||
// KV_SERIALIZE(unlockedBalance)
|
||||
// KV_SERIALIZE(numUnspentOutputs)
|
||||
// KV_SERIALIZE(isUsed)
|
||||
// KV_SERIALIZE(numBlocksToUnlock)
|
||||
// KV_SERIALIZE(unlocked_balance)
|
||||
// KV_SERIALIZE(num_unspent_outputs)
|
||||
// KV_SERIALIZE(is_used)
|
||||
// KV_SERIALIZE(num_blocks_to_unlock)
|
||||
// END_KV_SERIALIZE_MAP()
|
||||
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
@@ -106,17 +106,17 @@ namespace monero {
|
||||
*/
|
||||
struct monero_account : public serializable_struct {
|
||||
boost::optional<uint32_t> index;
|
||||
boost::optional<string> primaryAddress;
|
||||
boost::optional<string> primary_address;
|
||||
boost::optional<uint64_t> balance;
|
||||
boost::optional<uint64_t> unlockedBalance;
|
||||
boost::optional<uint64_t> unlocked_balance;
|
||||
boost::optional<string> tag;
|
||||
vector<monero_subaddress> subaddresses;
|
||||
// BEGIN_KV_SERIALIZE_MAP()
|
||||
// KV_SERIALIZE(index)
|
||||
// KV_SERIALIZE(primaryAddress)
|
||||
// KV_SERIALIZE(primary_address)
|
||||
// KV_SERIALIZE(label)
|
||||
// KV_SERIALIZE(balance)
|
||||
// KV_SERIALIZE(unlockedBalance)
|
||||
// KV_SERIALIZE(unlocked_balance)
|
||||
// KV_SERIALIZE(tag)
|
||||
// KV_SERIALIZE(subaddresses)
|
||||
// END_KV_SERIALIZE_MAP()
|
||||
@@ -145,8 +145,8 @@ namespace monero {
|
||||
struct monero_transfer : serializable_struct {
|
||||
shared_ptr<monero_tx_wallet> tx;
|
||||
boost::optional<uint64_t> amount;
|
||||
boost::optional<uint32_t> accountIndex;
|
||||
boost::optional<uint32_t> numSuggestedConfirmations;
|
||||
boost::optional<uint32_t> account_index;
|
||||
boost::optional<uint32_t> num_suggested_confirmations;
|
||||
|
||||
virtual boost::optional<bool> getIsIncoming() const = 0; // derived class must implement
|
||||
shared_ptr<monero_transfer> copy(const shared_ptr<monero_transfer>& src, const shared_ptr<monero_transfer>& tgt) const;
|
||||
@@ -162,7 +162,7 @@ namespace monero {
|
||||
* Models an incoming transfer of funds to the wallet.
|
||||
*/
|
||||
struct monero_incoming_transfer : public monero_transfer {
|
||||
boost::optional<uint32_t> subaddressIndex;
|
||||
boost::optional<uint32_t> subaddress_index;
|
||||
boost::optional<string> address;
|
||||
|
||||
shared_ptr<monero_incoming_transfer> copy(const shared_ptr<monero_transfer>& src, const shared_ptr<monero_transfer>& tgt) const;
|
||||
@@ -177,7 +177,7 @@ namespace monero {
|
||||
* Models an outgoing transfer of funds from the wallet.
|
||||
*/
|
||||
struct monero_outgoing_transfer : public monero_transfer {
|
||||
vector<uint32_t> subaddressIndices;
|
||||
vector<uint32_t> subaddress_indices;
|
||||
vector<string> addresses;
|
||||
vector<shared_ptr<monero_destination>> destinations;
|
||||
|
||||
@@ -195,14 +195,14 @@ namespace monero {
|
||||
* All transfers are returned except those that do not meet the criteria defined in this request.
|
||||
*/
|
||||
struct monero_transfer_request : public monero_transfer {
|
||||
boost::optional<bool> isIncoming;
|
||||
boost::optional<bool> is_incoming;
|
||||
boost::optional<string> address;
|
||||
vector<string> addresses;
|
||||
boost::optional<uint32_t> subaddressIndex;
|
||||
vector<uint32_t> subaddressIndices;
|
||||
boost::optional<uint32_t> subaddress_index;
|
||||
vector<uint32_t> subaddress_indices;
|
||||
vector<shared_ptr<monero_destination>> destinations;
|
||||
boost::optional<bool> hasDestinations;
|
||||
boost::optional<shared_ptr<monero_tx_request>> txRequest;
|
||||
boost::optional<bool> has_destinations;
|
||||
boost::optional<shared_ptr<monero_tx_request>> tx_request;
|
||||
|
||||
shared_ptr<monero_transfer_request> copy(const shared_ptr<monero_transfer>& src, const shared_ptr<monero_transfer>& tgt) const;
|
||||
shared_ptr<monero_transfer_request> copy(const shared_ptr<monero_transfer_request>& src, const shared_ptr<monero_transfer_request>& tgt) const;
|
||||
@@ -215,11 +215,11 @@ namespace monero {
|
||||
* Models a Monero output with wallet extensions.
|
||||
*/
|
||||
struct monero_output_wallet : public monero_output {
|
||||
boost::optional<uint32_t> accountIndex;
|
||||
boost::optional<uint32_t> subaddressIndex;
|
||||
boost::optional<bool> isSpent;
|
||||
boost::optional<bool> isUnlocked;
|
||||
boost::optional<bool> isFrozen;
|
||||
boost::optional<uint32_t> account_index;
|
||||
boost::optional<uint32_t> subaddress_index;
|
||||
boost::optional<bool> is_spent;
|
||||
boost::optional<bool> is_unlocked;
|
||||
boost::optional<bool> is_frozen;
|
||||
|
||||
shared_ptr<monero_output_wallet> copy(const shared_ptr<monero_output>& src, const shared_ptr<monero_output>& tgt) const;
|
||||
shared_ptr<monero_output_wallet> copy(const shared_ptr<monero_output_wallet>& src, const shared_ptr<monero_output_wallet>& tgt) const;
|
||||
@@ -235,8 +235,8 @@ namespace monero {
|
||||
* All outputs are returned except those that do not meet the criteria defined in this request.
|
||||
*/
|
||||
struct monero_output_request : public monero_output_wallet {
|
||||
vector<uint32_t> subaddressIndices;
|
||||
boost::optional<shared_ptr<monero_tx_request>> txRequest;
|
||||
vector<uint32_t> subaddress_indices;
|
||||
boost::optional<shared_ptr<monero_tx_request>> tx_request;
|
||||
|
||||
// TODO: necessary to override all super classes?
|
||||
shared_ptr<monero_output_request> copy(const shared_ptr<monero_output>& src, const shared_ptr<monero_output>& tgt) const;
|
||||
@@ -250,8 +250,8 @@ namespace monero {
|
||||
* Models a Monero transaction in the context of a wallet.
|
||||
*/
|
||||
struct monero_tx_wallet : public monero_tx {
|
||||
vector<shared_ptr<monero_incoming_transfer>> incomingTransfers;
|
||||
boost::optional<shared_ptr<monero_outgoing_transfer>> outgoingTransfer;
|
||||
vector<shared_ptr<monero_incoming_transfer>> incoming_transfers;
|
||||
boost::optional<shared_ptr<monero_outgoing_transfer>> outgoing_transfer;
|
||||
boost::optional<string> note;
|
||||
|
||||
shared_ptr<monero_tx_wallet> copy(const shared_ptr<monero_tx>& src, const shared_ptr<monero_tx>& tgt) const;
|
||||
@@ -269,17 +269,17 @@ namespace monero {
|
||||
* All transactions are returned except those that do not meet the criteria defined in this request.
|
||||
*/
|
||||
struct monero_tx_request : public monero_tx_wallet {
|
||||
boost::optional<bool> isOutgoing;
|
||||
boost::optional<bool> isIncoming;
|
||||
vector<string> txIds;
|
||||
boost::optional<bool> hasPaymentId;
|
||||
vector<string> paymentIds;
|
||||
boost::optional<bool> is_outgoing;
|
||||
boost::optional<bool> is_incoming;
|
||||
vector<string> tx_ids;
|
||||
boost::optional<bool> has_payment_id;
|
||||
vector<string> payment_ids;
|
||||
boost::optional<uint64_t> height;
|
||||
boost::optional<uint64_t> minHeight;
|
||||
boost::optional<uint64_t> maxHeight;
|
||||
boost::optional<uint64_t> includeOutputs;
|
||||
boost::optional<shared_ptr<monero_transfer_request>> transferRequest;
|
||||
boost::optional<shared_ptr<monero_output_request>> outputRequest;
|
||||
boost::optional<uint64_t> min_height;
|
||||
boost::optional<uint64_t> max_height;
|
||||
boost::optional<uint64_t> include_outputs;
|
||||
boost::optional<shared_ptr<monero_transfer_request>> transfer_request;
|
||||
boost::optional<shared_ptr<monero_output_request>> output_request;
|
||||
|
||||
// TODO: necessary to override all super classes?
|
||||
shared_ptr<monero_tx_request> copy(const shared_ptr<monero_tx>& src, const shared_ptr<monero_tx>& tgt) const;
|
||||
@@ -293,9 +293,9 @@ namespace monero {
|
||||
* Monero integrated address model.
|
||||
*/
|
||||
struct monero_integrated_address : public serializable_struct {
|
||||
string standardAddress;
|
||||
string paymentId;
|
||||
string integratedAddress;
|
||||
string standard_address;
|
||||
string payment_id;
|
||||
string integrated_address;
|
||||
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
};
|
||||
@@ -315,21 +315,21 @@ namespace monero {
|
||||
*/
|
||||
struct monero_send_request : public serializable_struct {
|
||||
vector<shared_ptr<monero_destination>> destinations;
|
||||
boost::optional<string> paymentId;
|
||||
boost::optional<string> payment_id;
|
||||
boost::optional<monero_send_priority> priority;
|
||||
boost::optional<uint32_t> mixin;
|
||||
boost::optional<uint32_t> ringSize;
|
||||
boost::optional<uint64_t> fee;
|
||||
boost::optional<uint32_t> accountIndex;
|
||||
vector<uint32_t> subaddressIndices;
|
||||
boost::optional<uint64_t> unlockTime;
|
||||
boost::optional<bool> canSplit;
|
||||
boost::optional<bool> doNotRelay;
|
||||
boost::optional<uint32_t> account_index;
|
||||
vector<uint32_t> subaddress_indices;
|
||||
boost::optional<uint64_t> unlock_time;
|
||||
boost::optional<bool> can_split;
|
||||
boost::optional<bool> do_not_relay;
|
||||
boost::optional<string> note;
|
||||
boost::optional<string> recipientName;
|
||||
boost::optional<uint64_t> belowAmount;
|
||||
boost::optional<bool> sweepEachSubaddress;
|
||||
boost::optional<string> keyImage;
|
||||
boost::optional<string> receipient_name;
|
||||
boost::optional<uint64_t> below_amount;
|
||||
boost::optional<bool> sweep_each_subaddress;
|
||||
boost::optional<string> key_image;
|
||||
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
};
|
||||
@@ -339,8 +339,8 @@ namespace monero {
|
||||
*/
|
||||
struct monero_key_image_import_result : public serializable_struct {
|
||||
boost::optional<uint64_t> height;
|
||||
boost::optional<uint64_t> spentAmount;
|
||||
boost::optional<uint64_t> unspentAmount;
|
||||
boost::optional<uint64_t> spent_amount;
|
||||
boost::optional<uint64_t> unspent_amount;
|
||||
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
};
|
||||
@@ -349,7 +349,7 @@ namespace monero {
|
||||
* Base class for results from checking a transaction or reserve proof.
|
||||
*/
|
||||
struct monero_check : public serializable_struct {
|
||||
bool isGood;
|
||||
bool is_good;
|
||||
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
};
|
||||
@@ -358,9 +358,9 @@ namespace monero {
|
||||
* Results from checking a transaction key.
|
||||
*/
|
||||
struct monero_check_tx : public monero_check {
|
||||
boost::optional<bool> inTxPool;
|
||||
boost::optional<uint64_t> numConfirmations;
|
||||
boost::optional<uint64_t> receivedAmount;
|
||||
boost::optional<bool> in_tx_pool;
|
||||
boost::optional<uint64_t> num_confirmations;
|
||||
boost::optional<uint64_t> received_amount;
|
||||
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
};
|
||||
@@ -369,8 +369,8 @@ namespace monero {
|
||||
* Results from checking a reserve proof.
|
||||
*/
|
||||
struct monero_check_reserve : public monero_check {
|
||||
boost::optional<uint64_t> totalAmount;
|
||||
boost::optional<uint64_t> unconfirmedSpentAmount;
|
||||
boost::optional<uint64_t> total_amount;
|
||||
boost::optional<uint64_t> unconfirmed_spent_amount;
|
||||
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
};
|
||||
|
||||
+13
-13
@@ -80,25 +80,25 @@ int main(int argc, const char* argv[]) {
|
||||
MINFO(txs[i]->serialize());
|
||||
}
|
||||
|
||||
// shared_ptr<monero_transfer_request> transferRequest = shared_ptr<monero_transfer_request>(new monero_transfer_request());
|
||||
// transferRequest->accountIndex = 0;
|
||||
// shared_ptr<monero_tx_request> txRequest = shared_ptr<monero_tx_request>(new monero_tx_request());
|
||||
// txRequest->isConfirmed = true;
|
||||
// transferRequest->txRequest = txRequest;
|
||||
// //txRequest->transferRequest = transferRequest;
|
||||
// vector<shared_ptr<monero_transfer>> transfers = wallet->get_transfers(*transferRequest);
|
||||
// shared_ptr<monero_transfer_request> transfer_request = shared_ptr<monero_transfer_request>(new monero_transfer_request());
|
||||
// transfer_request->account_index = 0;
|
||||
// shared_ptr<monero_tx_request> tx_request = shared_ptr<monero_tx_request>(new monero_tx_request());
|
||||
// tx_request->is_confirmed = true;
|
||||
// transfer_request->tx_request = tx_request;
|
||||
// //tx_request->transfer_request = transfer_request;
|
||||
// vector<shared_ptr<monero_transfer>> transfers = wallet->get_transfers(*transfer_request);
|
||||
// if (transfers.empty()) throw runtime_error("Transfers should not be empty");
|
||||
// for (const shared_ptr<monero_transfer>& transfer : transfers) {
|
||||
// if (*transfer->accountIndex != 0) throw runtime_error("Account should be 0");
|
||||
// if (!*transfer->tx->isConfirmed) throw runtime_error("Transfer should be confirmed");
|
||||
// if (*transfer->account_index != 0) throw runtime_error("Account should be 0");
|
||||
// if (!*transfer->tx->is_confirmed) throw runtime_error("Transfer should be confirmed");
|
||||
// }
|
||||
|
||||
// shared_ptr<monero_tx_request> txRequest = shared_ptr<monero_tx_request>(new monero_tx_request());
|
||||
// txRequest->isConfirmed = true;
|
||||
// vector<shared_ptr<monero_tx_wallet>> txs = wallet->get_txs(*txRequest);
|
||||
// shared_ptr<monero_tx_request> tx_request = shared_ptr<monero_tx_request>(new monero_tx_request());
|
||||
// tx_request->is_confirmed = true;
|
||||
// vector<shared_ptr<monero_tx_wallet>> txs = wallet->get_txs(*tx_request);
|
||||
// if (txs.empty()) throw runtime_error("Txs should not be empty");
|
||||
// for (const shared_ptr<monero_tx_wallet>& tx : txs) {
|
||||
// if (!*tx->isConfirmed) throw runtime_error("Tx should be confirmed");
|
||||
// if (!*tx->is_confirmed) throw runtime_error("Tx should be confirmed");
|
||||
// }
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user