about summary refs log tree commit diff stats
path: root/pcoin.cpp
Commit message (Collapse)AuthorAgeFilesLines
* made changes to be compatible with minerbot's new "username" format vs. the ↵login2021-12-121-1/+15
| | | | | | | | old "~username" format Made this change so that new "!minercoin ask" awarded minercoins will still show up in tcoin without losing old !minercoins awarded. In other words, the inflation will continue until morale improves.
* New pcoin function to change pcoin keyslogin2021-11-201-1/+106
| | | | This will allow pcoin accounts to be transferred from one person to another
* pcoin_keys fixedlogin2021-10-171-9/+36
| | | | Thanks to ~jmjl, I was able to find that pcoin_keys didn't work. To fix it, tcoin uses sneaky magic but with stdin isntead of an argument, and a new library imported called popen2, that lets me send both stdin and receive stdout, to successfully get "ls <path to the pcoin_keys directory>" to work (it execl's another instance of the tcoin comand so that it runs under setuid instead of as the original user who ran it.
* Update the way pcoin_keys works to use a folder/directory instead of a ↵login2021-06-301-20/+40
| | | | | | | | | | single file This is preparing tcoin/pcoin for the automatic registration of program accounts. Eventually, I want program accounts to be tradeable by there being a way to regenerate a new key. So, send the current key to whomever you want the program account to be used by, then the new owner regenerates the key to complete the transfer. The old owner will no longer be able to use the old key to operate the new account. The key is long and the key generation random enough for key collisions to be virtually impossible.
* Better way to handle 5 argumentslogin (__tcoin) (tilde.my.to)2021-02-031-3/+4
| | | | | | Improved the way 5 arguments were handled, where the intention was to send a message along with the amount and receiver, with a new error code and a slightly modified error message.
* Fixed an unhandled case of too many arguments in 'tcoin send'login (__tcoin) (tilde.my.to)2021-02-031-0/+6
| | | | | Fixed a case of too many arguments in 'tcoin send' that wasn't handled. Thank you for finding this ~julian.
* More buffer overflows fixedlogin (__tcoin) (tilde.my.to)2021-01-311-22/+24
| | | | | | | | There were many more places where I had hardcoded values, but should have used strlen() or sizeof(). I have gone through tcoin.cpp and pcoin.cpp, found those, and fixed them. Hopefully, this is all of them.
* Fixed buffer overflow because of hardcoded lengthslogin (__tcoin) (tilde.my.to)2021-01-311-3/+3
| | | | | | | | In user_has_initialised(..), the path lengths were hardcoded. This has now been changed to being calculated via sizeof(). In get_file_value and add_file_value, strlen() was used. This has also been replaced with sizeof().
* Refactored send function in tcoin and pcoinlogin (tilde.institute)2020-10-091-44/+76
| | | | | Refactored the send function in tcoin and pcoin, and in the process, fixed a bug in pcoin's silentsend function.
* Fixed bug in date generation for messages on OpenBSD systemslogin (tilde.institute)2020-09-221-2/+10
| | | | On OpenBSD, the equivalent of %_d is %e. This is fixed for OpenBSD/tilde.institute type systems now.
* Updated tcoin.cpp and pcoin.cpplogin (tilde.institute)2020-07-141-1/+0
| | | | | | 1. Removed unneeded WHOAMI_PATH preprocessor constant from pcoin.cpp. 2. Updated WHOAMI_PATH for tilde.institute to use "id -ru" to get the real uid on OpenBSD (/usr/bin/whoami doesn't get the real username on OpenBSD).
* Nobody's perfect: .n\n -> .\n\n in tcoin.cpp and pcoin.cpplogin (envs.net)2020-02-221-3/+3
| | | | | And I don't know how to clean my commits after having pushed them to remote origin/master. Maybe a Git stash and hard reset?
* Made a minor mistake in pcoin.cpp regarding symbolic constant ↵login (tilde.temm)2020-02-211-1/+1
| | | | | | | | | | TCOIN_MSG_LENGTH_LIMIT I made a switch from TCOIN_MSG_LENGTH to TCOIN_MSG_LENGTH_LIMIT for the symbolic constant representing the maximum number of characters of a transaction message. I changed all instances of the symbolic constant to this new name in tcoin.cpp, but forgot to do it in one instance in pcoin.cpp. This goes on to show that I need to develop tests for tcoin and pcoin, as well as start using getopt from util-linux for proper options handling.
* Implemented message-character limits in tcoin.cpp and pcoin.cpplogin (tilde.temm)2020-02-211-0/+30
| | | | | | | | | | | | | After having received a 10000-character transaction message from ~jan6@envs.net, I finally came around to implementing character limits on transaction messages. Previously, I was of the opinion that one should be able to send a movie as a transaction message if one so wished. I took inspiration for an appropriate character limit from Australia's NPP (New Payments Platform), which has a 280-character limit on transaction messages. I strongly suspect this limit came from Twitter's analysis of tweets in different languages and Twitter research that concluded that a 280-character tweet was the appropriate length of tweet. A transaction message is supposedly like a tweet with some money sent along with it.
* Added silentsend with message case to pcoin.cpplogin (tilde.temm)2020-02-211-0/+15
| | | | | | | | I don't know how I missed this, because I remember coming across this deficiency before. I had missed a case, where silentsend is requested but with a message. Previously, it would fail without any message to stdout or stderr (only a return code). Now, silentsend with a message works even on pcoin.cpp (tcoin.cpp already had this change).
* Merge branch 'master' of https://github.com/login000/tcoinlogin (tilde.temm)2020-02-211-3/+9
|\ | | | | | | | | I made a mistake. I should have done this before making my commits. That's the only reason why this merge is necessary.
| * Many instances of \u23CE were left unmodified, so those were changed toologin (envs.net)2020-02-221-3/+9
| | | | | | | | | | | | I had forgotten to change \u23CE to <new-line> and introduce a check for <vertical-tab> in many many places in tcoin.cpp and pcoin.cpp. I should probably put these things in some kind of function so I don't repeat myself. I'll probably do that in a future commit.
* | Some more errors (specifically, fatal errors) were taken out into symbolic ↵login (tilde.temm)2020-02-211-10/+16
|/ | | | | | constants I had forgotten to handle the fatal errors and take the error numbers out into symbolic constants. I have now done that in tcoin.cpp and pcoin.cpp
* Separated error codes out into symbolic constants in tcoin.cpp and pcoin.cpplogin (envs.net)2020-02-221-40/+70
| | | | This doesn't change functionality. It is simply a refactor that separates error codes out into symbolic constants in tcoin.cpp and pcoin.cpp.
* Replacing newlines and vertical tabs in messages with <new-line> and ↵login (envs.net)2020-02-211-1/+3
| | | | | | <vertical-tab> Newlines and vertical tabs in messages are replaced with <new-line> and <vertical-tab> to prevent transaction spoofing inside a message.
* Improving messaging around messageslogin2019-11-261-6/+53
| | | | The title is confusing, sorry. "No messages found" is shown in tcoin and pcoin when no messages are found (and this no-message message has one newline above and one newline below it instead of two newlines above it as before).
* Improving the messaging around sending transaction messageslogin2019-11-151-12/+52
| | | | | | | | | | | Several changes were made that were difficult to separate into separate commits. Since features are directly committed to master, there are no feature branches. The high-level list of changes is as follows: 1. Fixed a bug in pcoin where using "pcoin send -s" for silentsend would forget to add the transaction message that provides a record of who transferred how much and when, even if there is no custom message appended (send_message(.) was not called). 2. Improved the help text to make it clear that sending messages could be done using silentsend too. 3. In several cases in tcoin and pcoin, certain ways of doing a silentsend would still send with verbose output because, by mistake, the option passed to send_message(.) was not changed from "verbose" to "silent". 4. In pcoin, there was the case of 6 arguments missing, where one does pcoin send -s <user> <amount> <message>. This case was handled in tcoin but not pcoin. Now, it is handled in pcoin too. 5. Now, when a custom message is sent in tcoin or pcoin, an additional text confirming the successful sending of the custom message as distinct from the one confirming the sending of the coins is displayed to the user.
* KROWBAR_OFF, DA_OFF and MINERCOIN_OFF are now treated as config definitions~login@aussies.space2019-11-141-4/+0
| | | | | | The KROWBAR_OFF, DA_OFF and MINERCOIN_OFF symbolic constants are now included in tcoin_defs.cpp and pcoin_defs.cpp and have been removed from the main source files, tcoin.cpp and pcoin.cpp. ntcoin has been modified to include #define KROWBAR_OFF, #define DA_OFF and #define MINERCOIN_OFF in pcoin_defs.cpp and tcoin_defs.cpp by default, since those three features are only (as of now) available on the tilde.town server and on no other server.
* Bugfix to disable minercoin-score addition in pcoin.cpp~login@aussies.space2019-11-141-1/+1
| | | | | | In pcoin.cpp, minercoin-score addition can be disabled by writing #define MINERCOIN_OFF near the symbolic-constant definitions. However, in one place, a check for the absence of the DA_OFF symbolic constant was being made instead of MINERCOIN_OFF. This is now fixed.
* Creates separate definition files for tcoin.cpp and pcoin.cpp~login@aussies.space2019-11-141-13/+1
| | | | | | I realised that different tilde servers will have different definitions but the same code otherwise, and 'git push' and 'git pull' to update the code on other servers would override those definitions. Thus, the tcoin.cpp and pcoin.cpp files now look the same for all tildeservers and have a #include "tcoin_defs.cpp" and #include "pcoin_defs.cpp" respectively. The configuration, which is in the form of #define symbolic constants, is stored in tcoin/bin/tcoin_defs.cpp and tcoin/bin/pcoin_defs.cpp. ntcoin is modified to create these two files with the right definitions. ntcoin is also modified so that compile_tcoin and compile_pcoin now include the -I option, which instructs the compiler to look for includes in additional directories, in this case, tcoin/bin .
* Fixing a bug with how time is calculated for messages~login@aussies.space2019-10-071-6/+5
| | | | Benjamin Harris (https://ben.tild3.org, https://github.com/benharri, and https://benharr.is) found a bug where the time recorded for transaction logs/messages was local server time instead of UTC. It should have been UTC no matter what the local time was.
* Fixing preprocessor constants~login@aussies.space2019-10-071-1/+1
| | | | To fix the preprocessor constants so that they point to the right directory for the tcoin and pcoin executables. This will be different depending on where the tcoin and pcoin executables are stored.
* Added symbolic constants (flags) to remove integrations~login@aussies.space2019-09-301-4/+19
| | | | Since not all places where tcoin runs have tildebot, minerbot and daily-adventure, these integrations are now disabled in the code through preprocessor directives (symbolic constants that act as flags)
* Fixed preprocessor directives for pcoin.cpp and tcoin.cpp~login@aussies.space2019-09-301-0/+18
| | | | pcoin.cpp and tcoin.cpp were missing the preprocessor directives generated by ntcoin. The right preprocessor directives are now included in both files.
* Removed redundant code in pcoin.cpplogin0002019-07-151-2/+0
| | | pcoin.cpp had redundant code in 'int main()', where user_amount was redeclared (and thus became a local variable that shadowed the global version inside 'int main()' (!). Fixed by removing the redeclared, redundant line.
* Added #define DEBUG, fixed pcoin error messagelogin0002019-06-251-7/+13
| | | | Added #define DEBUG and put a few check statements under it. Fixed error message in pcoin that suggested the incorrect "add_internal_balance" amount when "internal_balance" owed to a particular user was not enough (and was lesser than the number of tildecoins being sent using the "send" command to said user). Also, fixed an error in retrieving the amount owed to a particular user when doing checks during the "send" command ("temp_program_sender_username" instead of "program_sender_username").
* Fixing daily-adventure integration in pcoin.cpplogin0002019-04-181-1/+1
| | | daily-adventure changed how it stores state, so this new code fixes daily-adventure integration to the new format that daily-adventure stores state in.
* Copied pcoin.cpp from tilde.townlogin0002019-03-101-0/+1796