1

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.

13
  • You are probably posting the same address twice. Please take an RPC capture, so one can see what you are posting on the server. Commented Dec 15, 2014 at 14:27
  • 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
    Commented Dec 15, 2014 at 14:29
  • Count outgoing sums of every address together before doing sendmany. Commented Dec 15, 2014 at 14:29
  • Is there PM in this site?
    – cmilian
    Commented Dec 15, 2014 at 14:33
  • 2
    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. Commented Dec 15, 2014 at 16:56

1 Answer 1

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 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}'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.