Example #1
0
 public void serialize(CryptoNote.ISerializer serializer)
 {
     if (serializer.functorMethod(address, "address") == null)
     {
         throw new RequestSerializationError();
     }
 }
Example #2
0
        private void saveUnlockTransactionsJobs(CryptoNote.ISerializer serializer)
        {
            auto index   = m_unlockTransactions.get <TransactionHashIndex>();
            auto wallets = m_walletsContainer.get <TransfersContainerIndex>();

            ulong jobsCount = index.size();

            serializer.functorMethod(jobsCount, "unlockTransactionsJobsCount");

            foreach (var j in index)
            {
                var containerIt = wallets.find(j.container);
                Debug.Assert(containerIt != wallets.end());

                var keyIt = m_walletsContainer.project <KeysIndex>(containerIt);
                Debug.Assert(keyIt != m_walletsContainer.get <KeysIndex>().end());

                UnlockTransactionJobDtoV2 dto = new UnlockTransactionJobDtoV2();
                dto.blockHeight          = j.blockHeight;
                dto.transactionHash      = j.transactionHash;
                dto.walletSpendPublicKey = keyIt.spendPublicKey;

                serializer.functorMethod(dto, "unlockTransactionsJob");
            }
        }
Example #3
0
            public void serialize(CryptoNote.ISerializer serializer, WalletService service)
            {
                serializer.functorMethod(addresses, "addresses");

                if (serializer.functorMethod(transfers, "transfers") == null)
                {
                    throw new RequestSerializationError();
                }

                serializer.functorMethod(changeAddress, "changeAddress");

                if (serializer.functorMethod(fee, "fee") == null)
                {
                    throw new RequestSerializationError();
                }

                if (serializer.functorMethod(anonymity, "anonymity") == null)
                {
                    anonymity = service.getDefaultMixin();
                }

                bool hasExtra     = serializer.functorMethod(extra, "extra");
                bool hasPaymentId = serializer.functorMethod(paymentId, "paymentId");

                if (hasExtra && hasPaymentId)
                {
                    throw new RequestSerializationError();
                }

                serializer.functorMethod(unlockTime, "unlockTime");
            }
Example #4
0
        private void loadUnlockTransactionsJobs(CryptoNote.ISerializer serializer)
        {
            auto index        = m_unlockTransactions.get <TransactionHashIndex>();
            auto walletsIndex = m_walletsContainer.get <KeysIndex>();

            ulong jobsCount = 0;

            serializer.functorMethod(jobsCount, "unlockTransactionsJobsCount");

            for (ulong i = 0; i < jobsCount; ++i)
            {
                UnlockTransactionJobDtoV2 dto = new UnlockTransactionJobDtoV2();
                serializer.functorMethod(dto, "unlockTransactionsJob");

                var walletIt = walletsIndex.find(dto.walletSpendPublicKey);
                if (walletIt != walletsIndex.end())
                {
                    UnlockTransactionJob job = new UnlockTransactionJob();
                    job.blockHeight     = dto.blockHeight;
                    job.transactionHash = dto.transactionHash;
                    job.container       = walletIt.container;

                    index.insert(std::move(job));
                }
            }
        }
Example #5
0
 public void serialize(CryptoNote.ISerializer serializer)
 {
     if (serializer.functorMethod(transactionHash, "transactionHash") == null)
     {
         throw new RequestSerializationError();
     }
 }
Example #6
0
        private void loadTransactions(CryptoNote.ISerializer serializer)
        {
            ulong count = 0;

            serializer.functorMethod(count, "transactionCount");

            m_transactions.get <RandomAccessIndex>().reserve(count);

            for (ulong i = 0; i < count; ++i)
            {
                WalletTransactionDtoV2 dto = new WalletTransactionDtoV2();
                serializer.functorMethod(dto, "transaction");

                WalletTransaction tx = new WalletTransaction();
                tx.state        = dto.state;
                tx.timestamp    = dto.timestamp;
                tx.blockHeight  = dto.blockHeight;
                tx.hash         = dto.hash;
                tx.totalAmount  = dto.totalAmount;
                tx.fee          = dto.fee;
                tx.creationTime = dto.creationTime;
                tx.unlockTime   = dto.unlockTime;
                tx.extra        = dto.extra;
                tx.isBase       = dto.isBase;

                m_transactions.get <RandomAccessIndex>().push_back(std::move(tx));
            }
        }
Example #7
0
 public void serialize(CryptoNote.ISerializer serializer)
 {
     if (serializer.functorMethod(fileName, "fileName") == null)
     {
         throw new RequestSerializationError();
     }
 }
Example #8
0
 // serialization
 public CryptoNote.ISerializer serialize(CryptoNote.ISerializer s, string name)
 {
     s.beginObject(name);
     s.functorMethod(m_blockchain, "blockchain");
     s.EndObject();
     return(s.functorMethod);
 }
Example #9
0
 public void serialize(CryptoNote.ISerializer serializer)
 {
     serializer.functorMethod(blockCount, "blockCount");
     serializer.functorMethod(knownBlockCount, "knownBlockCount");
     serializer.functorMethod(localDaemonBlockCount, "localDaemonBlockCount");
     serializer.functorMethod(lastBlockHash, "lastBlockHash");
     serializer.functorMethod(peerCount, "peerCount");
 }
Example #10
0
        private void loadKeyListAndBalances(CryptoNote.ISerializer serializer, bool saveCache)
        {
            ulong walletCount;

            serializer.functorMethod(walletCount, "walletCount");

            m_actualBalance  = 0;
            m_pendingBalance = 0;
            m_deletedKeys.Clear();

            HashSet <Crypto.PublicKey> cachedKeySet = new HashSet <Crypto.PublicKey>();
            auto index = m_walletsContainer.get <KeysIndex>();

            for (uint i = 0; i < walletCount; ++i)
            {
                Crypto.PublicKey spendPublicKey = new Crypto.PublicKey();
                ulong            actualBalance;
                ulong            pendingBalance;
                serializer.functorMethod(spendPublicKey, "spendPublicKey");

                if (saveCache)
                {
                    serializer.functorMethod(actualBalance, "actualBalance");
                    serializer.functorMethod(pendingBalance, "pendingBalance");
                }

                cachedKeySet.Add(spendPublicKey);

                var it = index.find(spendPublicKey);
                if (it == index.end())
                {
                    m_deletedKeys.emplace(std::move(spendPublicKey));
                }
                else if (saveCache)
                {
                    m_actualBalance  += actualBalance;
                    m_pendingBalance += pendingBalance;

//C++ TO C# CONVERTER TODO TASK: Only lambda expressions having all locals passed by reference can be converted to C#:
//ORIGINAL LINE: index.modify(it, [actualBalance, pendingBalance](WalletRecord& wallet)
                    index.modify(it, (WalletRecord wallet) =>
                    {
                        wallet.actualBalance  = actualBalance;
                        wallet.pendingBalance = pendingBalance;
                    });
                }
            }

            foreach (var wallet in index)
            {
                if (cachedKeySet.count(wallet.spendPublicKey) == 0)
                {
                    m_addedKeys.Add(wallet.spendPublicKey);
                }
            }
        }
Example #11
0
        private void loadTransfersSynchronizer(CryptoNote.ISerializer serializer)
        {
            string transfersSynchronizerData;

            serializer.functorMethod(transfersSynchronizerData, "transfersSynchronizer");

            std::stringstream stream = new std::stringstream(transfersSynchronizerData);

            m_synchronizer.load(stream);
        }
Example #12
0
            public void serialize(CryptoNote.ISerializer serializer)
            {
                bool r = serializer.functorMethod(firstBlockIndex, "firstBlockIndex");

                r &= serializer.functorMethod(blockCount, "blockCount");

                if (!r)
                {
                    throw new RequestSerializationError();
                }
            }
Example #13
0
        public void serialize(CryptoNote.ISerializer serializer)
        {
            bool r = serializer.functorMethod(address, "address");

            r &= serializer.functorMethod(amount, "amount");

            if (!r)
            {
                throw new RequestSerializationError();
            }
        }
Example #14
0
        private void saveTransfersSynchronizer(CryptoNote.ISerializer serializer)
        {
            std::stringstream stream = new std::stringstream();

            m_synchronizer.save(stream);
            stream.flush();

            string transfersSynchronizerData = stream.str();

            serializer.functorMethod(transfersSynchronizerData, "transfersSynchronizer");
        }
Example #15
0
        private void saveTransactions(CryptoNote.ISerializer serializer)
        {
            ulong count = m_transactions.size();

            serializer.functorMethod(count, "transactionCount");

            foreach (var tx in m_transactions)
            {
                WalletTransactionDtoV2 dto = new WalletTransactionDtoV2(tx);
                serializer.functorMethod(dto, "transaction");
            }
        }
Example #16
0
 public void serialize(CryptoNote.ISerializer serializer)
 {
     serializer.functorMethod(state, "state");
     serializer.functorMethod(transactionHash, "transactionHash");
     serializer.functorMethod(blockIndex, "blockIndex");
     serializer.functorMethod(timestamp, "timestamp");
     serializer.functorMethod(isBase, "isBase");
     serializer.functorMethod(unlockTime, "unlockTime");
     serializer.functorMethod(amount, "amount");
     serializer.functorMethod(fee, "fee");
     serializer.functorMethod(transfers, "transfers");
     serializer.functorMethod(extra, "extra");
     serializer.functorMethod(paymentId, "paymentId");
 }
Example #17
0
            public void serialize(CryptoNote.ISerializer serializer, WalletService service)
            {
                if (serializer.functorMethod(threshold, "threshold") == null)
                {
                    throw new RequestSerializationError();
                }

                if (serializer.functorMethod(anonymity, "anonymity") == null)
                {
                    anonymity = service.getDefaultMixin();
                }

                serializer.functorMethod(addresses, "addresses");
                serializer.functorMethod(destinationAddress, "destinationAddress");
            }
Example #18
0
        private void saveTransfers(CryptoNote.ISerializer serializer)
        {
            ulong count = m_transfers.size();

            serializer.functorMethod(count, "transferCount");

            foreach (var kv in m_transfers)
            {
                ulong txId = kv.first;

                WalletTransferDtoV2 tr = new WalletTransferDtoV2(kv.second);

                serializer.functorMethod(txId, "transactionId");
                serializer.functorMethod(tr, "transfer");
            }
        }
Example #19
0
            public void serialize(CryptoNote.ISerializer serializer)
            {
                serializer.functorMethod(addresses, "addresses");

                if (serializer.functorMethod(blockHash, "blockHash") == serializer.functorMethod(firstBlockIndex, "firstBlockIndex"))
                {
                    throw new RequestSerializationError();
                }

                if (serializer.functorMethod(blockCount, "blockCount") == null)
                {
                    throw new RequestSerializationError();
                }

                serializer.functorMethod(paymentId, "paymentId");
            }
Example #20
0
        private void saveKeyListAndBalances(CryptoNote.ISerializer serializer, bool saveCache)
        {
            ulong walletCount = m_walletsContainer.get <RandomAccessIndex>().size();

            serializer.functorMethod(walletCount, "walletCount");
            foreach (var wallet in m_walletsContainer.get <RandomAccessIndex>())
            {
                serializer.functorMethod(wallet.spendPublicKey, "spendPublicKey");

                if (saveCache)
                {
                    serializer.functorMethod(wallet.actualBalance, "actualBalance");
                    serializer.functorMethod(wallet.pendingBalance, "pendingBalance");
                }
            }
        }
Example #21
0
            public void serialize(CryptoNote.ISerializer serializer)
            {
                if (serializer.functorMethod(spendSecretKeys, "spendSecretKeys") == null)
                {
                    //TODO: replace it with error codes
                    throw new RequestSerializationError();
                }

                bool hasNewAddress = serializer.functorMethod(newAddress, "newAddress");
                bool hasScanHeight = serializer.functorMethod(scanHeight, "scanHeight");

                /* Can't specify both that it is a new address, and a height to begin
                 * scanning from */
                if (hasNewAddress && hasScanHeight)
                {
                    throw new RequestSerializationError();
                }
            }
Example #22
0
        private void loadTransfers(CryptoNote.ISerializer serializer)
        {
            ulong count = 0;

            serializer.functorMethod(count, "transferCount");

            m_transfers.reserve(count);

            for (ulong i = 0; i < count; ++i)
            {
                ulong txId = 0;
                serializer.functorMethod(txId, "transactionId");

                WalletTransferDtoV2 dto = new WalletTransferDtoV2();
                serializer.functorMethod(dto, "transfer");

                WalletTransfer tr = new WalletTransfer();
                tr.address = dto.address;
                tr.amount  = dto.amount;
                tr.type    = (WalletTransferType)dto.type;

                m_transfers.emplace_back(std::piecewise_construct, std::forward_as_tuple(txId), std::forward_as_tuple(std::move(tr)));
            }
        }
Example #23
0
 public void serialize(CryptoNote.ISerializer serializer)
 {
 }
Example #24
0
 public void serialize(CryptoNote.ISerializer serializer)
 {
     serializer.functorMethod(address, "address");
     serializer.functorMethod(amount, "amount");
 }
Example #25
0
 public void serialize(CryptoNote.ISerializer serializer)
 {
     serializer.functorMethod(integratedAddress, "integratedAddress");
 }
Example #26
0
 public void serialize(CryptoNote.ISerializer serializer)
 {
     serializer.functorMethod(fusionReadyCount, "fusionReadyCount");
     serializer.functorMethod(totalOutputCount, "totalOutputCount");
 }
Example #27
0
 public void serialize(CryptoNote.ISerializer serializer)
 {
     serializer.functorMethod(transactionHash, "transactionHash");
 }
Example #28
0
 public void serialize(CryptoNote.ISerializer serializer)
 {
     serializer.functorMethod(scanHeight, "scanHeight");
 }
Example #29
0
 public void serialize(CryptoNote.ISerializer serializer)
 {
     serializer.functorMethod(addresses, "addresses");
 }
Example #30
0
 public void serialize(CryptoNote.ISerializer serializer)
 {
     serializer.functorMethod(items, "items");
 }