#pragma once #include "daemon/MoneroDaemonModel.h" using namespace std; using namespace monero; /** * Public library interface. */ namespace monero { /** * Models a result of syncing a wallet. */ struct MoneroSyncResult { uint64_t numBlocksFetched; bool receivedMoney; MoneroSyncResult() {} MoneroSyncResult(const uint64_t numBlocksFetched, const bool receivedMoney) : numBlocksFetched(numBlocksFetched), receivedMoney(receivedMoney) {} }; /** * Models a Monero subaddress. */ struct MoneroSubaddress : public SerializableStruct { boost::optional accountIndex; boost::optional index; boost::optional address; boost::optional label; boost::optional balance; boost::optional unlockedBalance; boost::optional numUnspentOutputs; boost::optional isUsed; boost::optional numBlocksToUnlock; // BEGIN_KV_SERIALIZE_MAP() // KV_SERIALIZE(accountIndex) // KV_SERIALIZE(index) // KV_SERIALIZE(address) // KV_SERIALIZE(label) // KV_SERIALIZE(balance) // KV_SERIALIZE(unlockedBalance) // KV_SERIALIZE(numUnspentOutputs) // KV_SERIALIZE(isUsed) // KV_SERIALIZE(numBlocksToUnlock) // END_KV_SERIALIZE_MAP() boost::property_tree::ptree toPropertyTree() const; //void merge(const shared_ptr& self, const shared_ptr& other); }; /** * Models a Monero account. */ struct MoneroAccount : public SerializableStruct { boost::optional index; boost::optional primaryAddress; boost::optional label; boost::optional balance; boost::optional unlockedBalance; boost::optional tag; vector subaddresses; // BEGIN_KV_SERIALIZE_MAP() // KV_SERIALIZE(index) // KV_SERIALIZE(primaryAddress) // KV_SERIALIZE(label) // KV_SERIALIZE(balance) // KV_SERIALIZE(unlockedBalance) // KV_SERIALIZE(tag) // KV_SERIALIZE(subaddresses) // END_KV_SERIALIZE_MAP() boost::property_tree::ptree toPropertyTree() const; }; // forward declarations struct MoneroTxWallet; struct MoneroTxRequest; /** * Models an outgoing transfer destination. */ struct MoneroDestination { boost::optional address; boost::optional amount; boost::property_tree::ptree toPropertyTree() const; }; /** * Models a base transfer of funds to or from the wallet. */ struct MoneroTransfer : SerializableStruct { shared_ptr tx; boost::optional amount; boost::optional accountIndex; boost::optional numSuggestedConfirmations; virtual boost::optional getIsIncoming() const = 0; // derived class must implement boost::optional getIsOutgoing() const { if (getIsIncoming() == boost::none) return boost::none; return !(*getIsIncoming()); } boost::property_tree::ptree toPropertyTree() const; virtual void merge(const shared_ptr& self, const shared_ptr& other); }; /** * Models an incoming transfer of funds to the wallet. */ struct MoneroIncomingTransfer : public MoneroTransfer { boost::optional subaddressIndex; boost::optional address; boost::optional getIsIncoming() const; boost::property_tree::ptree toPropertyTree() const; void merge(const shared_ptr& self, const shared_ptr& other); }; /** * Models an outgoing transfer of funds from the wallet. */ struct MoneroOutgoingTransfer : public MoneroTransfer { vector subaddressIndices; vector addresses; vector> destinations; boost::optional getIsIncoming() const; boost::property_tree::ptree toPropertyTree() const; void merge(const shared_ptr& self, const shared_ptr& other); }; /** * Configures a request to retrieve transfers. * * All transfers are returned except those that do not meet the criteria defined in this request. */ struct MoneroTransferRequest : public MoneroTransfer { boost::optional isIncoming; boost::optional address; vector addresses; boost::optional subaddressIndex; vector subaddressIndices; vector> destinations; boost::optional hasDestinations; boost::optional> txRequest; boost::optional getIsIncoming() const; boost::property_tree::ptree toPropertyTree() const; bool meetsCriteria(MoneroTransfer* transfer) const; }; /** * Models a Monero output with wallet extensions. */ struct MoneroOutputWallet : public MoneroOutput { boost::optional accountIndex; boost::optional subaddressIndex; boost::optional isSpent; boost::optional isUnlocked; boost::optional isFrozen; boost::property_tree::ptree toPropertyTree() const; }; /** * Configures a request to retrieve wallet outputs (i.e. outputs that the wallet has or had the * ability to spend). * * All outputs are returned except those that do not meet the criteria defined in this request. */ struct MoneroOutputRequest : public MoneroOutputWallet { vector subaddressIndices; boost::optional> txRequest; boost::property_tree::ptree toPropertyTree() const; bool meetsCriteria(MoneroOutputWallet* output) const; }; /** * Models a Monero transaction in the context of a wallet. */ struct MoneroTxWallet : public MoneroTx { vector> incomingTransfers; boost::optional> outgoingTransfer; boost::optional note; bool getIsIncoming() const; bool getIsOutgoing() const; boost::property_tree::ptree toPropertyTree() const; void merge(const shared_ptr& self, const shared_ptr& other); void merge(const shared_ptr& self, const shared_ptr& other); }; /** * Configures a request to retrieve transactions. * * All transactions are returned except those that do not meet the criteria defined in this request. */ struct MoneroTxRequest : public MoneroTxWallet { boost::optional isOutgoing; boost::optional isIncoming; vector txIds; boost::optional hasPaymentId; vector paymentIds; boost::optional minHeight; boost::optional maxHeight; boost::optional includeOutputs; boost::optional> transferRequest; boost::optional> outputRequest; boost::property_tree::ptree toPropertyTree() const; bool meetsCriteria(MoneroTxWallet* tx) const; }; /** * Monero integrated address model. */ struct MoneroIntegratedAddress : public SerializableStruct { string standardAddress; string paymentId; string integratedAddress; boost::property_tree::ptree toPropertyTree() const; }; /** * Enumerates Monero network types. */ enum MoneroSendPriority : uint8_t { DEFAULT = 0, UNIMPORTANT, NORMAL, ELEVATED }; /** * Configures a request to send/sweep funds or create a payment URI. * * TODO: allow setAddress(), setAmount() for default destination? */ struct MoneroSendRequest : public SerializableStruct { vector> destinations; boost::optional paymentId; boost::optional priority; boost::optional mixin; boost::optional ringSize; boost::optional fee; boost::optional accountIndex; vector subaddressIndices; boost::optional unlockTime; boost::optional canSplit; boost::optional doNotRelay; boost::optional note; boost::optional recipientName; boost::optional belowAmount; boost::optional sweepEachSubaddress; boost::optional keyImage; boost::property_tree::ptree toPropertyTree() const; }; /** * Models results from importing key images. */ struct MoneroKeyImageImportResult : public SerializableStruct { boost::optional height; boost::optional spentAmount; boost::optional unspentAmount; boost::property_tree::ptree toPropertyTree() const; }; /** * Base class for results from checking a transaction or reserve proof. */ struct MoneroCheck : public SerializableStruct { bool isGood; boost::property_tree::ptree toPropertyTree() const; }; /** * Results from checking a transaction key. */ struct MoneroCheckTx : public MoneroCheck { boost::optional inTxPool; boost::optional numConfirmations; boost::optional receivedAmount; boost::property_tree::ptree toPropertyTree() const; }; /** * Results from checking a reserve proof. */ struct MoneroCheckReserve : public MoneroCheck { boost::optional totalAmount; boost::optional unconfirmedSpentAmount; boost::property_tree::ptree toPropertyTree() const; }; }