monero-integrations / monerophp

Monero PHP library + JsonRPC Client
MIT License
116 stars 76 forks source link

transfer error: not enough money #127

Closed php-wizard closed 3 years ago

php-wizard commented 3 years ago

I have an issue when using monerophp's transfer call from a non multisig wallet ( has multisig_import_needed to false).

getbalance gives:

object(stdClass)#1752 (6) {
["balance"]=>
int(26615980000)
["blocks_to_unlock"]=>
int(0)
["multisig_import_needed"]=>
bool(false)
["per_subaddress"]=>
array(1) {
[0]=>
object(stdClass)#1757 (9) {
["account_index"]=>
int(0)
["address"]=>
string(95) "55GazT88iFV1Qcu7RgKU4NQTz76c5CZscHVjtxt71iYt4xLeS8YXwMHa81kJvkcSnkbcGpZM1e1YBE4ivWS8BRh4Vs9VEfF"
["address_index"]=>
int(0)
["balance"]=>
int(26615980000)
["blocks_to_unlock"]=>
int(0)
["label"]=>
string(15) "Primary account"
["num_unspent_outputs"]=>
int(1)
["time_to_unlock"]=>
int(0)
["unlocked_balance"]=>
int(26615980000)
}
}
["time_to_unlock"]=>
int(0)
["unlocked_balance"]=>
int(26615980000)
}

transfergives:

RuntimeException : Request have return error: not enough money;Request: {"jsonrpc":"2.0","method":"transfer","params":{"destinations":[{"amount":26352445130,"address":"73a4nWuvkYoYoksGurDjKZQcZkmaxLaKbbeiKzHnMmqKivrCzq5Q2JtJG1UZNZFqLPbQ3MiXCk2Q5bdwdUNSr7X9QrPubkn"}],"mixin":10,"get_tx_key":true,"account_index":0,"subaddr_indices":"","priority":2,"do_not_relay":false,"ringsize":11}};

The balance is sufficient and covers the fees IMO. My daemon version is monero-x86_64-linux-gnu-v0.17.2.0/monerod and monero-x86_64-linux-gnu-v0.17.2.0/monero-wallet-rpc

php-wizard commented 3 years ago

PHP code


$walletRPC = new walletRPC("127.0.0.1", "123", false);
        try {
            $walletRPC->close_wallet();
        } catch(\Exception $e) {
            // do nothing. wallet already closed
        }

        $open_wallet = $walletRPC->open_wallet($wallet_name, '');
        $walletRPC->refresh();
        $balanceJson = self::arrayToJson($walletRPC->get_balance());
        var_dump($balanceJson);

        $transfer = self::arrayToJson($walletRPC->transfer(sprintf("%.12f",$amount),$address));
php-wizard commented 3 years ago

I will give you an example stagenet wallet where i experience the issue, so that you can debug it yourself if you need

php-wizard commented 3 years ago

SOLVED: did not have enough balance to cover the fee, that's why. I was wrong