<p>I had this problem on a NOMP pool recently, I will share how we fixed it. For us, the problem was that a user had used the same address twice, but added some whitespace to their username the second time. So NOMP wouldn't recognize it as a duplicate, but the <code>sendmany</code> command would still fail. The solution for us was to do two things.</p>

<ol>
<li>Eliminate the whitespace from workers' names. <a href="https://github.com/UNOMP/unified-node-open-mining-portal/commit/ef82fcf5dabdefa146921c668b3db8f8393e6fc9" rel="nofollow">This commit</a> shows how to do that.</li>
<li>Combine payouts together when there is more than one worker with the same address. The code for that is shown below.</li>
</ol>

<p>In paymentProcessor.js, change</p>

<pre><code>var address = worker.address = (worker.address || getProperAddress(w));
worker.sent = addressAmounts[address] = satoshisToCoins(toSend);
</code></pre>

<p>to</p>

<pre><code>var address = worker.address = (worker.address || getProperAddress(w)).trim();
if (!worker.sent) {
    worker.sent = 0;
}
worker.sent += satoshisToCoins(toSend);
if (!(address in addressAmounts)) {
    addressAmounts[address] = 0;
}
addressAmounts[address] += satoshisToCoins(toSend);
</code></pre>

<hr>

<p>If you want to know more about what caused this, the problem here is just what was explained in the error: there are duplicate addresses in the JSON object.</p>

<p>For example, I generated a new address of my own (1PSXKQdR5nG8T5ueG76RaWwhdwqv9JJWzy) and ran:</p>

<pre><code>./bitcoin-cli sendmany "" '{"1PSXKQdR5nG8T5ueG76RaWwhdwqv9JJWzy":0.01, "1PSXKQdR5nG8T5ueG76RaWwhdwqv9JJWzy":0.01}'
</code></pre>

<p>And the error was: </p>

<pre><code>Invalid parameter, duplicated address: 1PSXKQdR5nG8T5ueG76RaWwhdwqv9JJWzy (code -8)
</code></pre>

<p>To fix this problem, you either need to (1) add up all the amounts and pay to the address in one go, or (2) do separate RPC <code>sendmany</code> RPC calls, making sure to not have any duplicates.</p>

<p>In my case, (1) would look like:</p>

<pre><code>./bitcoin-cli sendmany "" '{"1PSXKQdR5nG8T5ueG76RaWwhdwqv9JJWzy":0.02}'
</code></pre>

<p>And (2) would look like:</p>

<pre><code>./bitcoin-cli sendmany "" '{"1PSXKQdR5nG8T5ueG76RaWwhdwqv9JJWzy":0.01}'
./bitcoin-cli sendmany "" '{"1PSXKQdR5nG8T5ueG76RaWwhdwqv9JJWzy":0.01}'
</code></pre>

CC BY-SA 3.0
2015-01-13T18:33:25.320Z
2015-03-30T04:47:21.220Z
2015-03-30T04:47:21.220Z
morsecoder
<p>Need help fixing this error. </p>

<p>Error trying to send payments with RPC sendmany {"code":-8,"message":"Invalid parameter, duplicated address</p>

<p>I a running a NOMP mining pool that has payment job breaking because there are two same wallet address payments in the same sendmany job. I need to limit amount sent to minimize chance of having the payment in the same transaction for a while until I get rid of this so that the payments go thru. Or, do something so that this is ignored. </p>

CC BY-SA 3.0
2014-12-15T14:27:01.527Z
You are probably posting the same address twice. Please take an RPC capture, so one can see what you are posting on the server.
Mikko Ohtamaa
CC BY-SA 3.0
2014-12-15T14:29:03.647Z
I know, this is a NOMP pool and there is a user that has two workers with the same address. How can I fix this? Is there a way to ignore this and submit the payments?
cmilian
CC BY-SA 3.0
2014-12-15T14:29:56.937Z
Count outgoing sums of every address together before doing `sendmany`.
Mikko Ohtamaa
CC BY-SA 3.0
2014-12-15T14:33:29.760Z
Is there PM in this site?
cmilian
CC BY-SA 3.0
2014-12-15T14:36:48.470Z
Count outgoing sums of every address together before doing sendmany... Not sure how to do this.
cmilian
CC BY-SA 3.0
2014-12-15T14:54:48.113Z
Is there a way to limit or control the amount of payments sendmany groups at a time? This may help me in these payouts while duplicate address removed.
cmilian
CC BY-SA 3.0
2014-12-15T15:44:50.740Z
@cmilian We don't know what your question is about now. Who or what is issuing these commands?
David Schwartz
CC BY-SA 3.0
2014-12-15T16:00:11.907Z
I a running a NOMP mining pool that has payment job breaking because there are two same wallet address payments in the same sendmany job.

I need to limit amount sent to minimize chance of having the payment in the same transaction for a while until I get rid of this so that the payments go thru.
cmilian
CC BY-SA 3.0
2014-12-15T16:22:03.580Z
@DavidSchwartz I a running a NOMP mining pool that has payment job breaking because there are two same wallet address payments in the same sendmany job. I need to limit amount sent to minimize chance of having the payment in the same transaction for a while until I get rid of this so that the payments go thru. Or, do something so that this is ignored. rather ignore duplicate wallet addresses.
cmilian
CC BY-SA 3.0
2014-12-15T16:53:34.223Z
@cmilian: [No, Stack Exchange does not support private messages.](http://meta.stackexchange.com/a/433/225338)
Nate Eldredge
CC BY-SA 3.0
2014-12-15T16:56:29.853Z
So, whatever code implements the "payment job" (i.e. the code that is calling `sendmany` in the first place) should detect when multiple outputs to the same address are requested, and combine them into one.  For instance, if you have a payment to address 1abc for BTC 0.1, and another to the same address for BTC 0.2, you should call `sendmany` asking for one payment to 1abd for BTC 0.3.
Nate Eldredge
CC BY-SA 3.0
2014-12-15T17:13:01.440Z
I understand, you are correct, that is the issue. trying to paste code to show.

[link] https://onedrive.live.com/redir?resid=CD88B09A5E2E741E!34171&authkey=!ACs6xjZnKgsjnBU&ithint=file%2ctxt [link]

how can I do that in this code?
cmilian
CC BY-SA 3.0
2014-12-16T10:21:40.737Z
Please edit your question to include the relevant code there.
Mikko Ohtamaa
<json-rpc><payment>
Error trying to send payments with RPC sendmany
cmilian
# Error trying to send payments with RPC sendmany

(Asked by: username_0 on 2014-12-15)

Need help fixing this error.

Error trying to send payments with RPC sendmany {"code":-8,"message":"Invalid parameter, duplicated address

I a running a NOMP mining pool that has payment job breaking because there are two same wallet address payments in the same sendmany job. I need to limit amount sent to minimize chance of having the payment in the same transaction for a while until I get rid of this so that the payments go thru. Or, do something so that this is ignored.

**Tags:** json-rpc, payment

> **Comments:**
> **username_1**: You are probably posting the same address twice. Please take an RPC capture, so one can see what you are posting on the server.  
> **username_0**: I know, this is a NOMP pool and there is a user that has two workers with the same address. How can I fix this? Is there a way to ignore this and submit the payments?  
> **username_1**: Count outgoing sums of every address together before doing `sendmany`.  
> **username_0**: Is there PM in this site?  
> **username_0**: Count outgoing sums of every address together before doing sendmany... Not sure how to do this.  
> **username_0**: Is there a way to limit or control the amount of payments sendmany groups at a time? This may help me in these payouts while duplicate address removed.  
> **username_2**: @username_0 We don't know what your question is about now. Who or what is issuing these commands?  
> **username_0**: I a running a NOMP mining pool that has payment job breaking because there are two same wallet address payments in the same sendmany job.  I need to limit amount sent to minimize chance of having the payment in the same transaction for a while until I get rid of this so that the payments go thru.  
> **username_0**: @username_2 I a running a NOMP mining pool that has payment job breaking because there are two same wallet address payments in the same sendmany job. I need to limit amount sent to minimize chance of having the payment in the same transaction for a while until I get rid of this so that the payments go thru. Or, do something so that this is ignored. rather ignore duplicate wallet addresses.  
> **username_3**: @username_0: [No, Stack Exchange does not support private messages.](http://meta.stackexchange.com/a/433/225338)  
> **username_3**: So, whatever code implements the "payment job" (i.e. the code that is calling `sendmany` in the first place) should detect when multiple outputs to the same address are requested, and combine them into one.  For instance, if you have a payment to address 1abc for BTC 0.1, and another to the same address for BTC 0.2, you should call `sendmany` asking for one payment to 1abd for BTC 0.3.  
> **username_0**: I understand, you are correct, that is the issue. trying to paste code to show.  [link] https://onedrive.live.com/redir?resid=CD88B09A5E2E741E!34171&authkey=!ACs6xjZnKgsjnBU&ithint=file%2ctxt [link]  how can I do that in this code?  
> **username_1**: Please edit your question to include the relevant code there.  

---

## 1 answers

### Answer by username_4 on 2015-01-13. Score: 1

I had this problem on a NOMP pool recently, I will share how we fixed it. For us, the problem was that a user had used the same address twice, but added some whitespace to their username the second time. So NOMP wouldn't recognize it as a duplicate, but the `sendmany` command would still fail. The solution for us was to do two things.

1. Eliminate the whitespace from workers' names. [This commit](https://github.com/UNOMP/unified-node-open-mining-portal/commit/ef82fcf5dabdefa146921c668b3db8f8393e6fc9) shows how to do that.
2. Combine payouts together when there is more than one worker with the same address. The code for that is shown below.

In paymentProcessor.js, change

```
var address = worker.address = (worker.address || getProperAddress(w));
worker.sent = addressAmounts[address] = satoshisToCoins(toSend);

```

to

```
var address = worker.address = (worker.address || getProperAddress(w)).trim();
if (!worker.sent) {
    worker.sent = 0;
}
worker.sent += satoshisToCoins(toSend);
if (!(address in addressAmounts)) {
    addressAmounts[address] = 0;
}
addressAmounts[address] += satoshisToCoins(toSend);

```

---

If you want to know more about what caused this, the problem here is just what was explained in the error: there are duplicate addresses in the JSON object.

For example, I generated a new address of my own (1PSXKQdR5nG8T5ueG76RaWwhdwqv9JJWzy) and ran:

```
./bitcoin-cli sendmany "" '{"1PSXKQdR5nG8T5ueG76RaWwhdwqv9JJWzy":0.01, "1PSXKQdR5nG8T5ueG76RaWwhdwqv9JJWzy":0.01}'

```

And the error was:

```
Invalid parameter, duplicated address: 1PSXKQdR5nG8T5ueG76RaWwhdwqv9JJWzy (code -8)

```

To fix this problem, you either need to (1) add up all the amounts and pay to the address in one go, or (2) do separate RPC `sendmany` RPC calls, making sure to not have any duplicates.

In my case, (1) would look like:

```
./bitcoin-cli sendmany "" '{"1PSXKQdR5nG8T5ueG76RaWwhdwqv9JJWzy":0.02}'

```

And (2) would look like:

```
./bitcoin-cli sendmany "" '{"1PSXKQdR5nG8T5ueG76RaWwhdwqv9JJWzy":0.01}'
./bitcoin-cli sendmany "" '{"1PSXKQdR5nG8T5ueG76RaWwhdwqv9JJWzy":0.01}'

```


---

