bcndev / bytecoin

GNU Lesser General Public License v3.0
230 stars 221 forks source link

One of referenced outputs is already spent #85

Closed ghost closed 4 years ago

ghost commented 6 years ago

Hi, I am build pool for testnet and testnet on http://amsterdam.bytecoins.world:8085/

Now I have problems with pool payments, because of

Json Error sending transaction from payment queue conflict height=2543 code=-103 msg=One of referenced outputs is already spent

error in walletd-verbose.log .

Looks like get_random_outputs generate identical outputs sometimes (with the same global_index), for different transactions. Then one transaction executes and going to mempool, and other stuck on payment queue with that error - because that output is already spent.

screenshot_2

I am right or it's mistake somewhere on my side ? How to fix it ? It's strange that other pools haven't that problem.

Currently pool makes 6 successful transactions , but only one is executed.

mounirrquiba commented 6 years ago

Hi @virgeny Same issue on bytecoin-pool.org, Fixed with this into lib/paymentProcessor.js

for (var worker in payments){
    var amount = parseInt(payments[worker]);
    if(config.payments.maxTransactionAmount && amount + commandAmount > config.payments.maxTransactionAmount) {
        amount = config.payments.maxTransactionAmount - commandAmount;
    }

    if(!transferCommands[commandIndex]) {
        transferCommands[commandIndex] = {
            redis: [],
            amount : 0,
            rpc: {
                             transaction: {
                                 anonymity: config.payments.mixin,
                                 payment_id: "",
                                 transfers: []
                             },
                             spend_addresses: [
                                config.poolServer.poolAddress
                             ],
                             change_address: config.poolServer.poolAddress,
                             optimization: "minimal"
                        }  
        };
    }

    transferCommands[commandIndex].rpc.transaction.transfers.push({amount: amount, address: worker});
    transferCommands[commandIndex].redis.push(['hincrby', config.coin + ':workers:' + worker, 'balance', -amount]);
    transferCommands[commandIndex].redis.push(['hincrby', config.coin + ':workers:' + worker, 'paid', amount]);
    transferCommands[commandIndex].amount += amount;

    addresses++;
    commandAmount += amount;
    if (addresses >= config.payments.maxAddresses || ( config.payments.maxTransactionAmount && commandAmount >= config.payments.maxTransactionAmount)) {
        continue; // <------ FIX HERE
        commandIndex++;
        addresses = 0;
        commandAmount = 0;
    }
}

then restart the payment process as many times as necessary, Happy Mining đź‘Ť

ghost commented 6 years ago

@virgeny I think you are right, it also happens to me right now. If I can find out something else I will comment here...

@mounirrquiba I do not understand how that can help this problem. I think that isn’t the solution.

mounirrquiba commented 6 years ago

@nilhcraiv isn't the solution, is just a hot fix, solution from daemon not from pool code.

ghost commented 6 years ago

Yes @mounirrquiba it works for the pool only, besides I think in the destination account the amount appears blocked, that is, it’s like a normal transaction but those coins are stuck...

ghost commented 6 years ago

Do you know if this has been resolved in the last update? my pool can not make payments at the same time... I’m using the @mounirrquiba solution :/

ghost commented 5 years ago

This error continues, you launch new updates but this is not fixed. This causes transfers that never arrive, you have to solve it as soon as possible.