There is certainly nothing wrong with using string-based numbers for accounting though. That probably the most reliable approach, and suitable for nearly all cases where performance and a possible space penalty don't matter.
Just fails on numbers like "one third", as in 1 divided by 3. Or on hitting any other prime numbers while dividing. How about cranking up ini_set('serialize_precision', 17); and maintaining code readability? Those bcmath functions must have been a pain in the ... Numbers such as 1/3 don't exist in accounting. There is always a defined precision (cents, satoshis, etc.). It is rare that you would ever do something like divide by three but if you do (e.g splitting an expense) you would need to explicitly address how to deal with the remainder to avoid books not balancing. Exactly, also how is integers different anyways? It's not like you can divide 1/3 with integer any better, nor does PHP support unsigned integers so your range is limited. Too limited. Since this is a financial application, the reliability of the numbers is what matters, not readability of code. I use wrappers to make the code more readable. But truth is I don't find bcmath to be a pain at all, I love it. I love having every single atomic unit accounted for with 100% certainty.
|
|
|
Some may wonder why the integration is using bcmath, my explaination below: Float, Decimal, Integer ? Mathematics in PHP & MySQLFloating point numbers are not accurate and should never be used for financial transactions. A few examples of this: $a = '35'; $b = '-34.99'; echo ($a + $b); Results in 0.009999999999998 instead of 0.01echo floor((0.1+0.7)*10); Results in 7 instead of the expected answer 8So we’re not able to use PHPs native operators for math calculations with decimals since those are treated as floats. Then we have integer. A much more suited choice for financial transactions. One thing to keep in mind if choosing integer is the php limits. Those are for 32-bit build of PHP limited to integers in the range of -2147483648 to 2147483647 while 64-bit -9 223 372 036 854 775 808 to 9 223 372 036 854 775 807Imagine you have 100k XMR. Since monero has up to 12 decimals, to store 1 monero we need a number like this: 10^12 = 1 000 000 000 000That’s more than a 32-bit build can handle right there. To store 100k XMR we would store:100000 * (10^12) = 100 000 000 000 000 000Let’s compare: 9 223 372 036 854 775 807 (64-bit limit) 100 000 000 000 000 000 (100k XMR) Well, it’s still within the range, but if we increase it to 10 million XMR not even 64-bit can handle it. Satoshi Nakamoto was pretty smart, he knew this. That’s probably why the limit is 21 million BTC. 1 Satoshi is the lowest unit of bitcoin, and 1 BTC = 100 000 000 Satoshi. Not only did he get it within the maximum integer value that can be stored. He also got it within the limit of floating point numbers, useful for languages like javascript, but that’s another story (you can read more here) 21 000 000 * 100,000,000 = 2100000000000000 Comparing again: 9223372036854775807 (64-bit limit) 2147483647 (32-bit limit) 2100000000000000 (Max BTC) As we can see, bitcoin fit’s within these ranges. We want our application to be scalable, there is always a good chance we’re going to want to add another currency with it’s own unique rules at one point. So monero cannot ultimately be stored as integer if we intend to preserve all the decimals. We could reduce the decimals to 8 like bitcoin. That will take care of it. But there is one unexplored alternative I’d like to present first: decimals and arbitrary precision math. If you enable an extension for PHP called “bcmath” you will be able to go beyond the limits of your system. With arbitrary precision mathematics you’ll have a binary calculator which supports numbers of any size and precision represented as strings. By using BCMath, we can do calculations and know with certainty that the numbers are 100% correct at all times, with every single satoshi accounted for. Not only that, but we get to store numbers like they are supposed to be stored in database. Just like they look. By using MySQL DECIMAL, we can store the smallest unit of monero as: 0.000000000001. Let us repeat the examples we did for float with bcmath: $a = '35'; $b = '-34.99'; echo bcadd($a,$b); Results in 0.01echo bc::floor(bcmul(bcadd('0.1','0.7'),'10')); Results in 8Large numbers is no problem at all, let us multiply the 64-bit max limit by itself: echo bcmul('9223372036854775807','9223372036854775807'); Results in 85070591730234615847396907784232501249Check for yourself (if you can even find a calculator doing that! hint: Wolfram Alpha) Similarly small amounts: echo bcmul('0.000000000001','0.000000000001'); 0.000000000000000000000001But before you do that, make sure to set bcscale() to something high enough. The script comes with a wrapper class for bc math, this will make it a tad easier to work with. As for downsides to using bcmath: - You need to have the bcmath extension (very easy to install, WHM/cPanel servers has it as a tick box)
- Not as fancy using functions to do operations as using + - * /, e.g bcadd(1,2) instead of 1+2
- Some functions available for php that is not integrated in bcmath, example is the php function “floor”, however there are re-implementations for this (I have included some in the wrapper)
- A bit slower… (But no big deal!)
So all calculations in the script are done using bcmath, the numbers are treated like strings and stored as decimals in the database. Only when we transfer money out do we convert to integer, and we do that outside of php as well (in json, with parameter JSON_NUMERIC_CHECK)
|
|
|
XMR Integration / DEMOFinally done with this script. The idea is to make it easier for people to setup their own monero accepting website. A working demo can help with that! This is a complete PHP integration of monero. Once setup you will have a working membership site with: This is very important step! Thank you! Is this suitable to create a Monero-accepting shop? There is no purchase item feature, only account funding. But the principle of processing payments works the same way, so it shouldn't be very hard to implement if you want that.
|
|
|
XMR Integration / DEMOFinally done with this script. The idea is to make it easier for people to setup their own monero accepting website. A working demo can help with that! This is a complete PHP integration of monero. Once setup you will have a working membership site with: - Login/Registration
- Generation of payment id
- Deposit of funds (automatically added to account after X confirmations)
- Withdraw of funds (added to processing queue and processed automatically)
- Admin Panel displaying current balances and other useful info (e.g status of daemon and wallet)
- With some minor changes, you can add multiple cryptonote types of currencies/assets
- The script comes with cron.php, which is the processing script. It can be setup to run forever in the background, or even as a cron job. Read the comment in cron.php for more info.
For install instructions simply open install.php Download here: https://github.com/TheKoziTwo/xmr-integrationStep by step install (install.php):Login/Registration:Account area:Admin area:There is no guide for how to setup daemon and simplewallet in "server mode". I have been working on a guide as well, but it's not posted anywhere yet, so I'll put some quick guidelines below: IntroductionWith bitcoin, transactions are identified with a unique address. Monero uses payment id instead to identify transactions. This means that your XMR receiving address will be the same for all users, but payment_id will be unique. Users transferring money to your site need to specify both address and payment id Setting up serverBitcoin has both wallet and daemon in one and the same software. Monero has split these into two separate applications. You have bitmonerod which is the daemon and simplewallet which is the wallet. This requires us to connect to two different services. Daemon (localhost:18081/rpc/)You need to launch daemon in server mode, to do so run it with: ./bitmonerod --rpc-bind-ip 127.0.0.1 --rpc-bind-port 18081 Thats all. Once you have a daemon running, you can connect to it from one or even multiple wallets. Wallet (localhost:18082/rpc/)First of all create a wallet as usual (if you have not already done so): simplewallet --generate-new-wallet mywallet.dat Enter a password (demo123), you don’t need to write down the seed, but you may. exit the wallet. In order to perform operations usings the API, the wallet must run in rpc server mode, to do so, run it with the following param (make sure the daemon is already running first): ./simplewallet --wallet-file mywallet.dat --password demo123 --rpc-bind-port 18082 Another example, if you have bound the daemon to an IP/PORT and also wants to bind the simplewallet, this example below shows how: ./simplewallet --daemon-host 192.168.10.54 --daemon-port 18081 --wallet-file mywallet.dat --rpc-bind-ip 192.168.10.54 --rpc-bind-port 18082 --password demo123 Now you should be able to access the wallet outside of your localhost also. IMPORTANT: When wallet is running in RPC mode it’s technically possible for hackers to empty your wallet if your port is open. You don’t want that, so make sure 18082 is closed.
|
|
|
Polo why you no let me buy??!
Keeps crashing my phone lol Oh well, up is a good direction, regardless.
If poloniex is slow on your phone it may help to set the chart to 6h. The script has to do a lot more work to show the chart at say "All" and it may freeze.
|
|
|
Something feels not right about this coin...
|
|
|
Calculation:
X = 25
Case A: X*250% = 62.5 X*2.5 = 62.5
Case B: X+(X*250%) = 87.5 X*3.5 = 87.5
If he still disagrees with Case A I would love to bet. Just let me know.
Your calculations don't make sense in this case. Just look: A: 25*250% = 6250% B: 25+(25*250%) = 25 + 6250% You just multiplied 25 with 250, that's not the same as 25 * 250%. Don't you know how to calculate percentage? Notice the "%" sign. See: 25*250%Are you saying 25*250% does not equal to 6250%? 6250% = 62.5 100% = 100/100 = 1 6250% = 6250/100 = 62.5 "%" is dimensionless Correct. So 2.5x and 250% is the same. Which was my point. And that I am willing to bet on, if the terms are clearly stated so that there can be no confusion.
|
|
|
Calculation:
X = 25
Case A: X*250% = 62.5 X*2.5 = 62.5
Case B: X+(X*250%) = 87.5 X*3.5 = 87.5
If he still disagrees with Case A I would love to bet. Just let me know.
Your calculations don't make sense in this case. Just look: A: 25*250% = 6250% B: 25+(25*250%) = 25 + 6250% You just multiplied 25 with 250, that's not the same as 25 * 250%. Don't you know how to calculate percentage? Notice the "%" sign. See: 25*250%
|
|
|
Ok, we have a bet then. I will bet you 0.4 BTC that something going up by 2.5x does not equal it going up 250%.
I will accept whatever rpietila says the correct answer.
Darlings, I'd like to know if I can get in on this action? illodin doesn't seem to have grasped elementary school math, and I'd love to make an easy 0.4 BTC! Ok, deal - we also have a bet. me too please? I would also like to bet more if you are interested. The wording of the bet isnt equal to he original statement hence the confusion. (see fluffyponys post above) If that's his point then the bet is off obviously. Calculation:X = 25 Case A: X*250% = 62.5X*2.5 = 62.5Case B: X+(X*250%) = 87.5X*3.5 = 87.5If he still disagrees with Case A I would love to bet. Just let me know.
|
|
|
Ok, we have a bet then. I will bet you 0.4 BTC that something going up by 2.5x does not equal it going up 250%.
I will accept whatever rpietila says the correct answer.
Darlings, I'd like to know if I can get in on this action? illodin doesn't seem to have grasped elementary school math, and I'd love to make an easy 0.4 BTC! Ok, deal - we also have a bet. me too please? I would also like to bet more if you are interested. edit: I am willing to bet according to terms stated here
|
|
|
If any alt reaches about 10-20% of Bitcoin's marketcap, Bitcoin is doomed in such a great probability that I'll sell mine (in favor of the alt).
Wasn't Litecoin at it's peak about $1 billion vs Bitcoin at the time around $10 billion? Now look at Litecoin... Litecoin, at its very highest peak reached ~0.05 LTC/BTC. Mostly it's been 0.03 or lower. Since supply is 4x that means LTC was worth 5*4 = 20% of bitcoin.
|
|
|
Bitcoin has the first mover advantage and massive adoption, no altcoin even comes close. To overtake bitcoin we'll need something that is as revolutionary as bitcoin is to the fiat/banking system. Monero is not that.
If minor improvements is all that it takes, we will soon enough see monero outcompeted by other currencies. Who's to say there won't be a zerocash type currency coming out where the parameteres are generated in a trusted manner? Suddenly everyone will flock to "the next big thing". Switching quickly between currencies like that means the storage of value is lost, nobody would use USD if they knew next month USD 2.0 will come out and their USD 1.0 will quickly decline in value. And then month after that USD 3.0 comes out with same result. This would be horrible for the ecosystem (and that without mentioning the huge costs of infrastructure change), and I don't think this will happen.
Monero serves a purpose, but for the majority of people the anonymity offered by monero isn't a revolution compared to bitcoin. Even if it was, bitcoin could implement it. That applies to any altcoin, too much is invested in bitcoin to let it be outcompeted. If there appears to be a serious threat, bitcoin will adapt.
It may turn out to be the case that bitcoin never goes anonym like monero. This could put a lot of pressure of it's back from governments that will instead be directed at monero and other anonymous currencies. Maybe that's a good thing.
Keep in mind that sidechains are coming, those could potentially make monero obsolete.
I realize this is swearing in the church, I like monero very much, but let's not get delusional. It's future success is not set in stone. I think at best monero can be a high liquid altcoin like LTC has been, and work as a complimentary currency to bitcoin. It may be, that bitcoin takes the spot as mainly storage of value, like gold is today. And that monero takes the spot as transactional currency. But it will never be the #1 crypto. That ship has sailed.
|
|
|
About 40k monero for about 150 BTC, that makes avg 0.00375
Is this really an efficient way to buy that many? I mean I can give the benefit of the doubt and say they wanted them quick, but still, what about in roughly 2K chunks with delays in between? I am sure many have experimented.... There may be other motives than just buying XMR. If I had to guess, this guy already owns a significant amount of XMR. Doing market buys helps drive the price in one direction. This is because people see a rising trend, they see that large buys are happening, that resistance is being broken. Big buys can draw a lot of attention and maybe even FOMO. With some patience the price could go above 0.004 and he will sit at a pretty hefty profit. Not only from his recent buy, but in total. Even if the price doesn't go that high who's to say the price stabilizing at say 0.0035 won't be a lot more profit for him than 0.003? It all depends on his current holdings. Consider another scenario: he kept the wall at 0.003 and waited for people to dump into it. Over time, it would be dumped away, what would happen then? The price would likely fall further because the trend is down. So I think trying to establish a trend is part of the reason. If his only goal was to accumulate as much XMR as he can, I agree that he would have done it differently.
|
|
|
About 40k monero for about 150 BTC, that makes avg 0.00375
|
|
|
Problem: Daemon server works for a day or so before getting this error multiple times and shutting down: [1426196083] libunbound[28839:0] error: can't create socket: Too many open files Environment:Ubuntu 14.04 Bitmonero Wallet v.0.8.8.7-1016712 Reproducible:1. Launch with ip binding ./bitmonerod --rpc-bind-ip 192.168.10.20 --rpc-bind-port 18081 Question:Any idea what this could be caused by? If you run it for a while (say half a day) and look at the open files in proc or using lsof, etc. what do you see? http://pastebin.com/raw.php?i=Q7hrxDZzThank you. You can track the issue here: https://github.com/monero-project/bitmonero/issues/240Thanks
|
|
|
Problem: Daemon server works for a day or so before getting this error multiple times and shutting down: [1426196083] libunbound[28839:0] error: can't create socket: Too many open files Environment:Ubuntu 14.04 Bitmonero Wallet v.0.8.8.7-1016712 Reproducible:1. Launch with ip binding ./bitmonerod --rpc-bind-ip 192.168.10.20 --rpc-bind-port 18081 Question:Any idea what this could be caused by? If you run it for a while (say half a day) and look at the open files in proc or using lsof, etc. what do you see? http://pastebin.com/raw.php?i=Q7hrxDZz
|
|
|
Problem: Daemon server works for a day or so before getting this error multiple times and shutting down: [1426196083] libunbound[28839:0] error: can't create socket: Too many open files Environment:Ubuntu 14.04 Bitmonero Wallet v.0.8.8.7-1016712 Reproducible:1. Launch with ip binding ./bitmonerod --rpc-bind-ip 192.168.10.20 --rpc-bind-port 18081 Question:Any idea what this could be caused by?
|
|
|
Problem: Can't restore correct wallet from seed. Environment:Ubuntu 14.04 Bitmonero Wallet v.0.8.8.7-1016712 Reproducible:1. Created new wallet (0 - English for seed language), was given this seed (Wallet id: 42GWgC): debut equip surfer tequila eldest heron eggs incur unnoticed nerves fawns ghost dawn revamp northern razor rafts wade calamity ocean zero evolved bygones cactus bygones 2. Exit wallet 3. Run: ./simplewallet --restore-deterministic-wallet 4. Enter wallet name: test.bin 5. Enter (no password) 6. Enter seed 7. Gets wallet id 428RFv, the seed is repeated and identical except from one word, " incur" has been replaced with " incline". Question:So basically, I'm getting another wallet restored than the one I should. What am I doing wrong? Why is that word replaced? Can you open this as a github issue so I can assign it to OranJuice? https://github.com/monero-project/bitmonero/issues/235
|
|
|
Problem: Can't restore correct wallet from seed. Environment:Ubuntu 14.04 Bitmonero Wallet v.0.8.8.7-1016712 Reproducible:1. Created new wallet (0 - English for seed language), was given this seed (Wallet id: 42GWgC): debut equip surfer tequila eldest heron eggs incur unnoticed nerves fawns ghost dawn revamp northern razor rafts wade calamity ocean zero evolved bygones cactus bygones 2. Exit wallet 3. Run: ./simplewallet --restore-deterministic-wallet 4. Enter wallet name: test.bin 5. Enter (no password) 6. Enter seed 7. Gets wallet id 428RFv, the seed is repeated and identical except from one word, " incur" has been replaced with " incline". Question:So basically, I'm getting another wallet restored than the one I should. What am I doing wrong? Why is that word replaced?
|
|
|
The install script install_monero.sh created by David to build monero was throwing errors in Ubuntu 14.04 (also it's not on the new website). I added some minor fixes, now worked for me (only in Ubuntu 14.04, not tried other versions). Posting source: http://pastebin.com/53w8LfjY
|
|
|
|