{"id":15146724,"url":"https://github.com/d4ndox/mnp","last_synced_at":"2025-06-11T15:10:42.363Z","repository":{"id":222006633,"uuid":"755988884","full_name":"d4ndox/mnp","owner":"d4ndox","description":"Monero named pipes (mnp) is a lightweight wallet, using named pipes, to monitor incoming payments on a shell like bash or zsh. mnp is developed with the UNIX-philosophy in mind and allows interaction through named pipes.","archived":false,"fork":false,"pushed_at":"2024-06-09T09:03:15.000Z","size":491,"stargazers_count":11,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-30T22:17:16.740Z","etag":null,"topics":["bash","linux","monero","monero-wallet-rpc","payment","tx-notify","wallet","zsh"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/d4ndox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-11T17:07:02.000Z","updated_at":"2024-10-02T11:08:00.000Z","dependencies_parsed_at":"2024-03-13T17:25:51.043Z","dependency_job_id":"ce2286cb-2503-43b2-9f1e-d4a6a1e76217","html_url":"https://github.com/d4ndox/mnp","commit_stats":null,"previous_names":["d4ndox/mnp"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d4ndox%2Fmnp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d4ndox%2Fmnp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d4ndox%2Fmnp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d4ndox%2Fmnp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/d4ndox","download_url":"https://codeload.github.com/d4ndox/mnp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237901410,"owners_count":19384384,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","linux","monero","monero-wallet-rpc","payment","tx-notify","wallet","zsh"],"created_at":"2024-09-26T12:04:11.301Z","updated_at":"2025-02-09T03:31:48.074Z","avatar_url":"https://github.com/d4ndox.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Monero Named Pipes\n\nMonero named pipes (mnp) is a lightweight wallet designed to monitor incoming payments within a Unix shell environment, such as bash or zsh. mnp is developed with the *UNIX-philosophy* in mind and uses named pipes for interaction, creating a set of files and directories within a specified directory. Default: */tmp/mywallet/*.\n\n\n```bash\n/tmp/mywallet/\n\ntx\n ├── txid_1\n │   └── \"subaddress_1\"\n ├── txid_2\n │   └── \"subaddress_2\"\n └── txid_3\n     └── \"paymentId_1\"\n```\n\nMonero Named Pipes enables users to control and track incoming payments through  command-line tools, facilitating seamless integration with existing  workflows.\n\n### Example\n\nInitialize and Setup\n\nA short example in four simple steps to give you an idea of how mnp works.\nFor more details, see \"How to set up a payment\".\n\n#### 1. Initalize mnp\n\n```bash\n# initialise the workdir\n$ mnp --init\n$ monero-wallet-rpc --tx-notify \"/usr/local/bin/mnp --confirmation 3 %s\"\n```\n\n#### 2. Monitor /tmp/mywallet/\n\nTo monitor /tmp/mywallet i recommend inotifywait. It efficiently waits for changes to files using Linux's inotify.\nThe operating system takes care of the rest.\n```sudo apt-get install inotify-tools```\n\n```bash\n#!/bin/bash\ninotifywait -m /tmp/mywallet -e create -r |\nwhile read dir action file; do\n    echo $file;\n    amount=$(cat ${dir}${file});\n    echo \"Received :\" $amount;\ndone\n```\nBe patient and wait for 3 confirmations.\n\n#### 3. Setup a payment\n\nThe amount is specified in the smallest unit piconero.\n\n```bash\n$ mnp-payment --amount 500000000000 --newaddr\nmonero:BbE3cKKZp7repvTCHknzg4TihjuMmjNy78VSofgnk28r26WczcZvPcufchGqqML7yKEYZY91tytH47eCSA6fCJRRNy7cqSM?tx_amount=0.500000000000\n```\n\nPipe the output to ```qrencode``` to create a QR-Code for your customer. \n\n#### 4. Close mnp\n\nClose the working directory /tmp/myallet/. If you stopped all monitoring you might want to close the workdir. (optional)\n\n```bash\n# remove the workdir /tmp/mywallet\n$ mnp --cleanup\n```\n\n\n## Command line option:\n\nmnp is called from monero-wallet-rpc --tx-notify or some other source.\n\n```bash\nUsage: mnp [OPTION] [TXID]\n\n   [TX_ID]\n\t   TXID is the transaction identifier passed from\n\t   monero-wallet-rpc --tx-notify or some other source.\n\n  --account [ACCOUNT]\n           Monero account number. 0 = default.\n\n  --notify-at [0,1,2,3] default = confirmed\n           0, none\n           1, txpool\n           2, confirmed\n           3, unlocked\n\n  --confirmation [n]\n           amount of blocks needed to confirm transaction.\n\n  --keep-open\n           Does not close the fifo pipe.\n\n  --init\n           create workdir for usage.\n\n  --cleanup\n           delete workdir.\n```\n\nmnp-payment is used to prepare a payment.\n\n```bash\nUsage: mnp-payment [OPTION] [PAYMENT_ID]\n\n  [PAYMENT_ID]\n\t\tPAYMENT_ID is a 16 hex unique char to\n\t\tidentify the payment. Returns an\n\t\tintegrated address.\n\n  -a  --account [ACCOUNT]\n               Monero account number. 0 = default.\n\n  -l, --list\n               list all subaddresses + address_indices.\n\n  -s  --subaddr [INDEX]\n               returns subaddress on INDEX.\n\n  -n  --newaddr\n               returns a new created subaddress.\n\n  -x  --amount [AMOUNT]\n               AMOUNT is specified in piconero.\n               returns a URI string.\n```\n\n\n## How to build mnp\n\n'libcurl' is required to build mnp. `apt-get install libcurl4`\n\n```bash\n$ cd mnp\n$ mkdir build\n$ cmake -DCMAKE_BUILD_TYPE=Release ../\n$ make\n$ make install\n```\n\n### Verify\n\ngpg_key : https://github.com/d4ndox/mnp/blob/master/doc/d4ndo%40proton.me.pub\n\n*Please also help audit the source code.*\n\n\n## How to run mnp?\n\n Monero Named Pipes uses monero-wallet-rpc which comes with the Monero Command-line Tools. Download @ getmonero.org.\n\n- [ ] Step 1) Start monerod. It keeps the blockchain in sync.\n- [ ] Step 2) Start monero-wallet-rpc --tx-notify \"/usr/bin/mnp %s\". It listens on rpc port and takes care of your wallet.\n\n```bash\n$ monerod\n$ monero-wallet-rpc --tx-notify \"/usr/local/bin/mnp --confirmation 3 %s\" --rpc-bind-ip 127.0.0.1 --rpc-bind-port 18083 --rpc-login username:password --wallet-file mywallet --prompt-for-password\n```\n\n### Config file ~/.mnp.ini:\n\nThe config file makes things easier. It is used by both `mnp` and `mnp-payment`.\n\n```bash\n; Monero named pipes (mnp)\n; Configuration file for mnp.\n\n[rpc]                           ;rpc host configuration\nuser = username                 ;rpc user\npassword = password             ;rpc password\nhost = 127.0.0.1                ;rpc ip address or domain\nport = 18083                    ;rpc port\n\n[mnp]                           ;general mnp configuration\nverbose = 0                     ;verbose mode\naccount = 0                     ;choose account\n\n[cfg]                           ;workdir configuration\nworkdir = /tmp/mywallet         ;wallet working directory\nmode = rwx------                ;permission of workdir rwxrwxrwx\npipe = rw-------                ;permission of pipes rwxrwxrwx\n```\n\n## Setting up a payment:\n\nTo set up a payment using mnp, you have several options based on your specific requirements:\n\n### 1. Simple Transfer (No Payment ID):\n\nFor simple transfers, such as donations or general payments, you can create a new subaddress and provide it to the payer.\n\n#### **Create a New Subaddress:**\n```bash\n$ mnp-payment --newaddr\nBdxcxb5WkE84HuNyzoZvTPincGgPkZFXKfeQkpwSHew1cWwNcBXN4bY9YXY9dAHfibRBCrX92JwzmASMXsfrRnQqMo3ubLB\n```\nThis command generates a new Monero subaddress, providing enhanced privacy and security for receiving payments.\n\n#### **List All Subaddresses:**\nTo list all existing subaddresses along with their indices, you can use:\n```bash\n$ mnp-payment --list\n0 \"A13iyF9bN7ReDPWW7FZoqd1Nwvhfh2UbAMBR4UeGPi1aWpERgmE3ChMeJZJ2RnkMueHdL7XXwdkQJ5As8XRhTKAhSwjahXd\"\n1 \"Bdxcxb5WkE84HuNyzoZvTPincGgPkZFXKfeQkpwSHew1cWwNcBXN4bY9YXY9dAHfibRBCrX92JwzmASMXsfrRnQqMo3ubLB\"\n```\nThis command lists all subaddresses associated with your Monero wallet, including the primary address (0).\n\n#### **Select a Specific Subaddress:**\nIf you prefer to specify a particular subaddress, you can do so by providing its index:\n```bash\n$ mnp-payment --subaddr 1\nBdxcxb5WkE84HuNyzoZvTPincGgPkZFXKfeQkpwSHew1cWwNcBXN4bY9YXY9dAHfibRBCrX92JwzmASMXsfrRnQqMo3ubLB\n```\nThis command selects the subaddress at index 1 for receiving payments.\n\n#### **Add an Amount:**\nAfter selecting a subaddress, you can specify the payment amount in piconero (the smallest unit of Monero):\n```bash\n$ mnp-payment --subaddr 1 --amount 650000\nmonero:Bdxcxb5WkE84HuNyzoZvTPincGgPkZFXKfeQkpwSHew1cWwNcBXN4bY9YXY9dAHfibRBCrX92JwzmASMXsfrRnQqMo3ubLB?tx_amount=0.000000650000\n```\nThis command prepares a payment with the specified amount and returns a Monero URI string, which can be provided to the payer.\n\n### 2. Including a Payment ID (For Matching Orders):\n\nIn scenarios where matching orders to payments is essential, such as retail transactions or invoicing, you can generate an integrated address with a payment ID.\n\n#### **Generate a Payment ID:**\nGenerate a unique 16-hex character payment ID using tools like OpenSSL:\n```bash\n# Create a random paymentid (16 hex character)\n$ mypaymentId=$(openssl rand -hex 8)\n$ echo $mypaymentId\ne02c381aa2227436\n```\nThis command generates a random 16-hex character payment ID.\n\n#### **Create an Integrated Address:**\nUse the generated payment ID to create an integrated address, combining it with your primary address:\n```bash\n# Create an integrated address.\n$ echo $mypaymentId | mnp-payment\nAAkPz3y5yNweDPWW7FZoqd1 ... 5kqxkfnou78gMMeg\n```\nThis command generates an integrated address with the provided payment ID, enabling efficient tracking of payments.\n\n#### **Add an Amount (Optional):**\nIf a specific amount needs to be included in the payment, you can do so using the **```--amount```** option:\n```bash\n $ echo $mypayment | mnp-payment --amount 50000\nmonero:AAkPz3y5yNweDPWW7FZoqd1Nwvhfh2UbAMBR4UeGPi1aWpERgmE3ChMeJZJ2RnkMueHdL7XXwdkQJ5As8XRhTKAhfT5kqxkfnou78gMMeg?tx_amount=0.000000050000\n```\nThis command sets the payment amount and returns a Monero URI string for inclusion in invoices or payment requests.\n\n### 3. Create a QR-Code (For Customer Convenience):\nTo facilitate easy payment by customers using mobile Monero wallets, you can generate a QR code from the payment URI.\n\n#### **Install QR Code Generator:**\nEnsure you have a QR code generator installed on your system. You can install qrencode using:\n```bash\nsudo apt-get install qrencode\n```\n#### **Generate QR Code:**\nUse qrencode to generate a QR code from the Monero URI string:\n```bash\nmnp-payment --subaddr 1 | tr -d '\\n' | qrencode -t UTF8\n```\n, ready for customer scanning. Monerujo has some problems with \\n terminated strings, so it is better to remove them.\n\nThese methods provide flexible options for setting up payments using mnp. Every output of ```mnp-payment``` can be used to create an QR-Code. \n\n\n## How to Monitor /tmp/wallet\n\n### Using a bash script:\n\n```bash\n#!/bin/bash\n\n# Function to handle reading from a named pipe\nread_pipe() {\n    local dir=\"$1\"\n    local file=\"$2\"\n    local amount\n\n    # Set timeout for cat command\n    if ! amount=$(timeout 60m cat \"${dir}/${file}\"); then\n        # Handle timeout - write to syslog and exit\n        echo \"Timeout occurred while reading from $file\" \u003e\u00262\n        logger \"Timeout occurred while reading from $file\"\n        exit 1\n    fi\n\n    echo \"Received from $file: $amount\"\n}\n\n# Trap SIGINT to clean up child processes\ntrap 'kill $(jobs -p); exit' SIGINT\n\n# Watch for new pipes using inotifywait\ninotifywait -m /tmp/mywallet -e create -r |\nwhile read dir action file; do\n    # Check if the created file is a named pipe\n    if [ -p \"${dir}/${file}\" ]; then\n        echo \"New pipe detected: $file\"\n        # Call function to read from pipe in a background process\n        read_pipe \"$dir\" \"$file\" \u0026\n    fi\ndone\n```\n\n### Using Python:\n\nThis allows interaction with any scripting language (Perl, Python, ...)\n\n```bash\n#!/bin/bash\nwhile inotifywait -m /tmp/mywallet -e create -r |\nwhile read dir action file; do\n    python check_payment.py ${dir}/${file} \u0026\ndone\n```\n\n### Very short bash script:\n\n```bash\nwhile [ ! –e ${tx} ]\n```\n\n## Information\n\nYou might consider to change the default color for 'ls' by adding this to your bashrc:\n```bash\n echo 'LS_COLORS=$LS_COLORS:\"pi=00;35\"' \u003e\u003e ~/.bashrc\n```\nThe default color of named pipes set by Ubuntu is a pain:\n\nLicence: »MIT«\n\nAuthor: »Unknown« (d4ndo)\n\n```bash\n\n     __\nw  c(..)o     (\n \\__(-)     __)\n     /\\    (\n    /(_)___)\n   w /|\n    | \\\n   m  m | Monero Named Pipes.\n```\n\n\nmnp is a hobby project. Fun has the highest priority.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd4ndox%2Fmnp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fd4ndox%2Fmnp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd4ndox%2Fmnp/lists"}