Skip to content

Commit

Permalink
Removed trailing whitespace.
Browse files Browse the repository at this point in the history
  • Loading branch information
d4ndox committed Mar 13, 2024
1 parent cef278a commit 2d18301
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 42 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Monero Named Pipes

Monero named pipes (mnp) is a leightweight payment processor, using named pipes, to monitor incoming payments on
Monero named pipes (mnp) is a leightweight payment processor, 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.

mnp will create a set of files and directories - allowing you to control and check for incoming payments with command line tools.
Expand Down Expand Up @@ -162,7 +162,7 @@ The config file makes things easier. It is used by both `mnp` and `mnp-payment`.
user = username ;rpc user
password = password ;rpc password
host = 127.0.0.1 ;rpc ip address or domain
port = 18083 ;rpc port
port = 18083 ;rpc port

[mnp] ;general mnp configuration
verbose = 0 ;verbose mode
Expand All @@ -187,7 +187,7 @@ $ ./mnp-payment --list

### Without payment Id

A simple transfer. Typically used for donations. If you have a small business or only issue a few
A simple transfer. Typically used for donations. If you have a small business or only issue a few
invoices a day, it is advised to create a sub-address for each invoice. This has privacy benefits.

```bash
Expand Down Expand Up @@ -278,7 +278,7 @@ $ echo "Thank you for your payment" $payment "piconero"
Thank you for your payment 25000 piconero
```

## How to Monitor /tmp/wallet
## How to Monitor /tmp/wallet

### Using Python:

Expand Down
26 changes: 13 additions & 13 deletions mnp-payment.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ int main(int argc, char **argv)
monero_wallet[i].saddr = NULL;
monero_wallet[i].idx = 0;
monero_wallet[i].reply = NULL;
}
}

for (int i = 0; i < END_RPC_SIZE; i++) {

Expand Down Expand Up @@ -249,9 +249,9 @@ int main(int argc, char **argv)
cJSON_Print(adr));
}
}
/*
* mnp-payment --subaddr 1

/*
* mnp-payment --subaddr 1
* returns subaddress
* mnp-payment --amount 10 --subaddr 1
* returns uri with subaddress at idx 1 + amount
Expand All @@ -271,7 +271,7 @@ int main(int argc, char **argv)
char *retaddr = delQuotes(cJSON_Print(adr));

monero_wallet[MK_URI].saddr = strndup(retaddr, MAX_ADDR_SIZE);

if (amount == NULL) {
fprintf(stdout, "%s\n", retaddr);
} else {
Expand All @@ -291,8 +291,8 @@ int main(int argc, char **argv)
free(retaddr);
}

/*
* mnp-payment --newaddr
/*
* mnp-payment --newaddr
* returns new created subaddress
* mnp-payment --amount 10 --newaddr
* returns uri with new subaddress, amount
Expand All @@ -307,7 +307,7 @@ int main(int argc, char **argv)
cJSON *address = cJSON_GetObjectItem(result, "address");
char *retaddr = delQuotes(cJSON_Print(address));
monero_wallet[MK_URI].saddr = strndup(retaddr, MAX_ADDR_SIZE);

if (amount == NULL) {
fprintf(stdout, "%s\n", retaddr);
} else {
Expand All @@ -327,8 +327,8 @@ int main(int argc, char **argv)
free(retaddr);
}

/*
* openssl rand --hex 8 | mnp-payment
/*
* openssl rand --hex 8 | mnp-payment
* returns integrated address.
* mnp-payment --amount 10 1234567890abcdef
* returns uri with new integrated adddress + paymentid + amount
Expand All @@ -337,7 +337,7 @@ int main(int argc, char **argv)
if (strlen(paymentId) != 16) {
fprintf(stderr, "Invalid payment Id. (16 characters hex)\n");
exit(EXIT_FAILURE);
}
}

monero_wallet[MK_IADDR].payid = strndup(paymentId, MAX_PAYID_SIZE);
if (0 > (ret = rpc_call(&monero_wallet[MK_IADDR]))) {
Expand Down Expand Up @@ -373,8 +373,8 @@ int main(int argc, char **argv)
}


/*
* read paymentId from stdin
/*
* read paymentId from stdin
*/
static char *readStdin(void)
{
Expand Down
18 changes: 9 additions & 9 deletions mnp.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ int main(int argc, char **argv)
(((perm[6] == 'r') * 4 | (perm[7] == 'w') * 2 | (perm[8] == 'x')));

if (DEBUG) fprintf(stderr, "mode_t = %03o and mode = %s\n", mode, config.cfg_mode);

if (DEBUG) printf("enum size = %d\n", END_RPC_SIZE);
struct rpc_wallet *monero_wallet = (struct rpc_wallet*)malloc(END_RPC_SIZE * sizeof(struct rpc_wallet));

Expand All @@ -220,7 +220,7 @@ int main(int argc, char **argv)
monero_wallet[i].fifo = NULL;
monero_wallet[i].idx = 0;
monero_wallet[i].reply = NULL;
}
}


for (int i = 0; i < END_RPC_SIZE; i++) {
Expand Down Expand Up @@ -321,24 +321,24 @@ int main(int argc, char **argv)
monero_wallet[GET_TXID].conf = confirm(&monero_wallet[GET_TXID]);

if (strcmp(monero_wallet[GET_TXID].payid, PAYNULL)) {
asprintf(&monero_wallet[GET_TXID].fifo, "%s/%s/%s",
asprintf(&monero_wallet[GET_TXID].fifo, "%s/%s/%s",
workdir, PAYMENT_DIR, monero_wallet[GET_TXID].payid);
} else {
asprintf(&monero_wallet[GET_TXID].fifo, "%s/%s/%s",
asprintf(&monero_wallet[GET_TXID].fifo, "%s/%s/%s",
workdir, TRANSFER_DIR, monero_wallet[GET_TXID].saddr);
}
if (verbose) fprintf(stderr, "fifo = %s\n", monero_wallet[GET_TXID].fifo);

if (stat(monero_wallet[GET_TXID].fifo, &sb) == 0 && S_ISFIFO(sb.st_mode)) {
/*NOP*/
} else {
mkfifo(monero_wallet[GET_TXID].fifo, mode);
mkfifo(monero_wallet[GET_TXID].fifo, mode);
}


/*
/*
* Start main loop
* jail. Don't leave this jail until all requirements
* jail. Don't leave this jail until all requirements
* are meet for payment.
*/
int jail = 1;
Expand Down Expand Up @@ -464,8 +464,8 @@ static void usage(int status)
}


/*
* read paymentId from stdin
/*
* read paymentId from stdin
*/
static char *readStdin(void)
{
Expand Down
32 changes: 16 additions & 16 deletions rpc_call.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,54 +66,54 @@ int rpc_call(struct rpc_wallet *monero_wallet)
rpc_params = NULL;
break;
case GET_BALANCE:
if (cJSON_AddNumberToObject(rpc_params, "account_index",
if (cJSON_AddNumberToObject(rpc_params, "account_index",
atoi(monero_wallet->account)) == NULL) ret = -1;
break;
case GET_LIST:
if (cJSON_AddNumberToObject(rpc_params, "account_index",
if (cJSON_AddNumberToObject(rpc_params, "account_index",
atoi(monero_wallet->account)) == NULL) ret = -1;
break;
case GET_SUBADDR:
if (cJSON_AddNumberToObject(rpc_params, "account_index",
if (cJSON_AddNumberToObject(rpc_params, "account_index",
atoi(monero_wallet->account)) == NULL) ret = -1;
cJSON *subarray = cJSON_CreateArray();
cJSON *index = cJSON_CreateNumber(monero_wallet->idx);
cJSON_AddItemToArray(subarray, index);
cJSON_AddItemToObject(rpc_params, "address_index", subarray);
break;
case NEW_SUBADDR:
if (cJSON_AddNumberToObject(rpc_params, "account_index",
if (cJSON_AddNumberToObject(rpc_params, "account_index",
atoi(monero_wallet->account)) == NULL) ret = -1;
break;
case MK_IADDR:
if (cJSON_AddNumberToObject(rpc_params, "account_index",
if (cJSON_AddNumberToObject(rpc_params, "account_index",
atoi(monero_wallet->account)) == NULL) ret = -1;
if (cJSON_AddStringToObject(rpc_params, "payment_id",
if (cJSON_AddStringToObject(rpc_params, "payment_id",
monero_wallet->payid) == NULL) ret = -1;
break;
case MK_URI:
if (cJSON_AddNumberToObject(rpc_params, "account_index",
if (cJSON_AddNumberToObject(rpc_params, "account_index",
atoi(monero_wallet->account)) == NULL) ret = -1;
if (cJSON_AddStringToObject(rpc_params, "address",
if (cJSON_AddStringToObject(rpc_params, "address",
monero_wallet->saddr) == NULL) ret = -1;
if (cJSON_AddStringToObject(rpc_params, "amount",
if (cJSON_AddStringToObject(rpc_params, "amount",
monero_wallet->amount) == NULL) ret = -1;
/* payment_id is depricated use integrated address instead */
/* payment_id is depricated use integrated address instead */
//if (monero_wallet->payid != NULL) {
// if (cJSON_AddStringToObject(rpc_params, "payment_id",
// if (cJSON_AddStringToObject(rpc_params, "payment_id",
// monero_wallet->payid) == NULL) ret = -1;
//}
break;
case SPLIT_IADDR:
if (cJSON_AddNumberToObject(rpc_params, "account_index",
if (cJSON_AddNumberToObject(rpc_params, "account_index",
atoi(monero_wallet->account)) == NULL) ret = -1;
if (cJSON_AddStringToObject(rpc_params, "integrated_address",
if (cJSON_AddStringToObject(rpc_params, "integrated_address",
monero_wallet->iaddr) == NULL) ret = -1;
break;
case GET_TXID:
if (cJSON_AddNumberToObject(rpc_params, "account_index",
if (cJSON_AddNumberToObject(rpc_params, "account_index",
atoi(monero_wallet->account)) == NULL) ret = -1;
if (cJSON_AddStringToObject(rpc_params, "txid",
if (cJSON_AddStringToObject(rpc_params, "txid",
monero_wallet->txid) == NULL) ret = -1;
break;
default:
Expand Down Expand Up @@ -212,6 +212,6 @@ char* get_method(enum monero_rpc_method method)
break;
default:
break;
}
}
return mtd;
}

0 comments on commit 2d18301

Please sign in to comment.