Wallet RPC Transfer method using different Account Indexes to transfer from always gives Not Enough Money Error available = 0.000000000000
macker4 opened this issue · 8 comments
I'm trying to use wallet rpc transfer with this library using different account indexes but I keep getting a N5tools5error16not_enough_moneyE: not enough money, available = 0.000000000000 error in wallet-rpc-log even though there is definately more than enough money in the account index I'm trying to transfer with. For example I use like this:
public function transfer($amount, $address, $accountTag = null){
try {
$result = $this->monerod->get_accounts($accountTag);
#Get all accounts belonging to the user
$accounts = $result['subaddress_accounts'];
#Collects all indexes of user-owned accounts
$accountIndexes = [];
foreach ($accounts as $index => $account) {
$accountIndexes[$index] = $account['account_index'];
}
#Transfer the requested amount using only the balance of the accounts belonging to the user
$this->monerod->transfer(($amount*1.000000000000), $address, $accountIndexes);
} catch (\Exception $exception) {
session()->flash('error', 'Unable to transfer, please try again later!');
I don't get the exception, just the not enough money error in wallet rpc logs. I have checked to make sure that it is indeed using the correct index number and it is (n° 7) as below shows when i dd the ($accountIndexes) like:
$this->monerod->transfer(($amount*1.000000000000), $address, dd($accountIndexes)); returns:
array:1 [
0 => 7
]
As you can see index 7 has enough:
Accounts with tag: d289d97a-59ce-43bd-bf8d-7316d68568be
Tag's description:
Account Balance Unlocked balance Label
7 86yAuY 0.164664967836 0.164664967836
------------------------------------------------------------------------------------
Total 0.164664967836 0.164664967836
Accounts with tag: 8fe11691-5515-4467-b570-d3ea6af44e6b
Tag's description:
Account Balance Unlocked balance Label
6 86FZSB 0.023600000000 0.023600000000
------------------------------------------------------------------------------------
Total 0.023600000000 0.023600000000
Accounts with tag: This is an example account tag
Tag's description:
Account Balance Unlocked balance Label
* 0 4AreFg 0.046417768213 0.046417768213 Primary account
------------------------------------------------------------------------------------
Total 0.046417768213 0.046417768213
The amount I'm trying to transfer is way smaller for example 0.006780000000 but still always gives the same error.
And here is a snippet of the wallet-rpc log level 4:
contrib/epee/include/net/http_protocol_handler.inl:421 HTTP HEAD:
2022-08-20 14:15:21.643 [RPC0] TRACE net.http contrib/epee/include/net/http_protocol_handler.inl:421 Host: 127.0.0.1:18083
2022-08-20 14:15:21.643 [RPC0] TRACE net.http contrib/epee/include/net/http_protocol_handler.inl:421 Accept: */*
2022-08-20 14:15:21.643 [RPC0] TRACE net.http contrib/epee/include/net/http_protocol_handler.inl:421 Accept-Encoding: gzip,deflate
2022-08-20 14:15:21.643 [RPC0] TRACE net.http contrib/epee/include/net/http_protocol_handler.inl:421 Content-type: application/json
2022-08-20 14:15:21.643 [RPC0] TRACE net.http contrib/epee/include/net/http_protocol_handler.inl:421 Content-Length: 312
2022-08-20 14:15:21.643 [RPC0] TRACE net.http contrib/epee/include/net/http_protocol_handler.inl:421
2022-08-20 14:15:21.643 [RPC0] INFO wallet.rpc src/wallet/wallet_rpc_server.h:67 HTTP [127.0.0.1] POST /json_rpc
2022-08-20 14:15:21.643 [RPC0] INFO wallet.rpc src/wallet/wallet_rpc_server.h:90 [127.0.0.1:39730 INC] Calling RPC method transfer
2022-08-20 14:15:21.643 [RPC0] TRACE wallet.rpc src/wallet/wallet_rpc_server.cpp:1062 on_transfer starts
2022-08-20 14:15:21.648 [RPC0] TRACE net contrib/epee/include/net/net_helper.h:460 READ ENDS: Success. bytes_tr: 478
2022-08-20 14:15:21.648 [RPC0] TRACE net.http contrib/epee/include/net/http_client.h:648 http_stream_filter::parse_cached_header(*)
2022-08-20 14:15:21.649 [RPC0] DEBUG wallet.wallet2 src/wallet/wallet2.cpp:10888 Using v15 rules
2022-08-20 14:15:21.649 [RPC0] WARNING wallet.wallet2 src/wallet/wallet2.cpp:7457 Requested ring size 1 too low, using 16
2022-08-20 14:15:21.649 [RPC0] DEBUG wallet.wallet2 src/wallet/wallet2.cpp:10888 Using v15 rules
2022-08-20 14:15:21.650 [RPC0] TRACE net contrib/epee/include/net/net_helper.h:460 READ ENDS: Success. bytes_tr: 479
2022-08-20 14:15:21.650 [RPC0] TRACE net.http contrib/epee/include/net/http_client.h:648 http_stream_filter::parse_cached_header(*)
2022-08-20 14:15:21.650 [RPC0] DEBUG wallet.wallet2 src/wallet/wallet2.cpp:10888 Using v5 rules
2022-08-20 14:15:21.651 [RPC0] TRACE net contrib/epee/include/net/net_helper.h:460 READ ENDS: Success. bytes_tr: 479
2022-08-20 14:15:21.651 [RPC0] TRACE net.http contrib/epee/include/net/http_client.h:648 http_stream_filter::parse_cached_header(*)
2022-08-20 14:15:21.651 [RPC0] DEBUG wallet.wallet2 src/wallet/wallet2.cpp:10888 Using v8 rules
2022-08-20 14:15:21.651 [RPC0] DEBUG wallet.wallet2 src/wallet/wallet2.cpp:10888 Using v8 rules
2022-08-20 14:15:21.652 [RPC0] TRACE net contrib/epee/include/net/net_helper.h:460 READ ENDS: Success. bytes_tr: 479
2022-08-20 14:15:21.652 [RPC0] TRACE net.http contrib/epee/include/net/http_client.h:648 http_stream_filter::parse_cached_header(*)
2022-08-20 14:15:21.652 [RPC0] DEBUG wallet.wallet2 src/wallet/wallet2.cpp:10888 Using v4 rules
2022-08-20 14:15:21.652 [RPC0] DEBUG wallet.wallet2 src/wallet/wallet2.cpp:10888 Using v8 rules
2022-08-20 14:15:21.652 [RPC0] DEBUG wallet.wallet2 src/wallet/wallet2.cpp:10888 Using v15 rules
2022-08-20 14:15:21.652 [RPC0] TRACE net contrib/epee/include/net/net_helper.h:460 READ ENDS: Success. bytes_tr: 479
2022-08-20 14:15:21.652 [RPC0] TRACE net.http contrib/epee/include/net/http_client.h:648 http_stream_filter::parse_cached_header(*)
2022-08-20 14:15:21.652 [RPC0] DEBUG wallet.wallet2 src/wallet/wallet2.cpp:10888 Using v13 rules
2022-08-20 14:15:21.652 [RPC0] DEBUG wallet.wallet2 src/wallet/wallet2.cpp:10888 Using v15 rules
2022-08-20 14:15:21.652 [RPC0] DEBUG wallet.wallet2 src/wallet/wallet2.cpp:10888 Using v15 rules
2022-08-20 14:15:21.654 [RPC0] TRACE net contrib/epee/include/net/net_helper.h:460 READ ENDS: Success. bytes_tr: 399
2022-08-20 14:15:21.655 [RPC0] TRACE net.http contrib/epee/include/net/http_client.h:648 http_stream_filter::parse_cached_header(*)
2022-08-20 14:15:21.655 [RPC0] DEBUG wallet.wallet2 src/wallet/wallet2.cpp:10888 Using v8 rules
2022-08-20 14:15:21.655 [RPC0] DEBUG wallet.wallet2 src/wallet/wallet2.cpp:9894 transfer: adding 0.006780000000, for a total of 0.006780000000
2022-08-20 14:15:21.655 [RPC0] DEBUG wallet.wallet2 src/wallet/wallet2.cpp:840 estimated bulletproof plus rct tx size for 1 inputs with ring size 16 and 2 outputs: 1492 (1120 saved)
2022-08-20 14:15:21.655 [RPC0] ERROR wallet.wallet2 src/wallet/wallet2.cpp:9922 needed_money + min_fee > balance_subtotal. THROW EXCEPTION: error::not_enough_money
2022-08-20 14:15:21.655 [RPC0] WARNING net.http src/wallet/wallet_errors.h:915 /root/source/monero/src/wallet/wallet2.cpp:9922:N5tools5error16not_enough_moneyE: not enough money, available = 0.000000000000, tx_amount = 0.006780000000
2022-08-20 14:15:21.655 [RPC0] INFO stacktrace src/common/stack_trace.cpp:133 Exception: tools::error::not_enough_money
2022-08-20 14:15:21.655 [RPC0] INFO stacktrace src/common/stack_trace.cpp:134 Unwound call stack:
2022-08-20 14:15:21.659 [RPC0] INFO stacktrace src/common/stack_trace.cpp:172 [1] 0x10d) [0x55e3a0195ccd]:__cxa_throw+0x10d) [0x55e3a0195ccd]
2022-08-20 14:15:21.659 [RPC0] INFO stacktrace src/common/stack_trace.cpp:172 [2] monero-wallet-rpc(+0x38b58e) [0x55e39fffa58e]
2022-08-20 14:15:21.659 [RPC0] INFO stacktrace src/common/stack_trace.cpp:172 [3] monero-wallet-rpc(+0x32ef3b) [0x55e39ff9df3b]
2022-08-20 14:15:21.659 [RPC0] INFO stacktrace src/common/stack_trace.cpp:172 [4] monero-wallet-rpc(+0x1372df) [0x55e39fda62df]
2022-08-20 14:15:21.659 [RPC0] INFO stacktrace src/common/stack_trace.cpp:172 [5] monero-wallet-rpc(+0x2387b8) [0x55e39fea77b8]
2022-08-20 14:15:21.659 [RPC0] INFO stacktrace src/common/stack_trace.cpp:172 [6] monero-wallet-rpc(+0x268143) [0x55e39fed7143]
2022-08-20 14:15:21.659 [RPC0] INFO stacktrace src/common/stack_trace.cpp:172 [7] monero-wallet-rpc(+0x216eed) [0x55e39fe85eed]
2022-08-20 14:15:21.659 [RPC0] INFO stacktrace src/common/stack_trace.cpp:172 [8] monero-wallet-rpc(+0x19f10e) [0x55e39fe0e10e]
2022-08-20 14:15:21.659 [RPC0] INFO stacktrace src/common/stack_trace.cpp:172 [9] monero-wallet-rpc(+0x19f507) [0x55e39fe0e507]
2022-08-20 14:15:21.659 [RPC0] INFO stacktrace src/common/stack_trace.cpp:172 [10] monero-wallet-rpc(+0x26b860) [0x55e39feda860]
2022-08-20 14:15:21.659 [RPC0] INFO stacktrace src/common/stack_trace.cpp:172 [11] monero-wallet-rpc(+0x26c1ad) [0x55e39fedb1ad]
2022-08-20 14:15:21.659 [RPC0] INFO stacktrace src/common/stack_trace.cpp:172 [12] monero-wallet-rpc(+0x26c29e) [0x55e39fedb29e]
2022-08-20 14:15:21.659 [RPC0] INFO stacktrace src/common/stack_trace.cpp:172 [13] monero-wallet-rpc(+0x15c105) [0x55e39fdcb105]
2022-08-20 14:15:21.659 [RPC0] INFO stacktrace src/common/stack_trace.cpp:172 [14] monero-wallet-rpc(+0x15cadb) [0x55e39fdcbadb]
2022-08-20 14:15:21.659 [RPC0] INFO stacktrace src/common/stack_trace.cpp:172 [15] monero-wallet-rpc(+0x178fe9) [0x55e39fde7fe9]
2022-08-20 14:15:21.659 [RPC0] INFO stacktrace src/common/stack_trace.cpp:172 [16] 0x11bcd) [0x7f552162cbcd]:_64-linux-gnu/libboost_thread.so.1.65.1(+0x11bcd) [0x7f552162cbcd]
2022-08-20 14:15:21.659 [RPC0] INFO stacktrace src/common/stack_trace.cpp:172 [17] 0x76db) [0x7f551f2d36db]:_64-linux-gnu/libpthread.so.0(+0x76db) [0x7f551f2d36db]
2022-08-20 14:15:21.659 [RPC0] INFO stacktrace src/common/stack_trace.cpp:172 [18] 0x3f) [0x7f551effc61f]:_64-linux-gnu/libc.so.6(clone+0x3f) [0x7f551effc61f]
2022-08-20 14:15:21.659 [RPC0] INFO stacktrace src/common/stack_trace.cpp:172
2022-08-20 14:15:21.660 [RPC0] TRACE net.http contrib/epee/include/net/http_protocol_handler.inl:604 HTTP_RESPONSE_HEAD: <<
2022-08-20 14:15:21.660 [RPC0] TRACE net.http contrib/epee/include/net/http_protocol_handler.inl:604 HTTP/1.1 200 Ok
2022-08-20 14:15:21.660 [RPC0] TRACE net.http contrib/epee/include/net/http_protocol_handler.inl:604 Server: Epee-based
2022-08-20 14:15:21.660 [RPC0] TRACE net.http contrib/epee/include/net/http_protocol_handler.inl:604 Content-Length: 109
2022-08-20 14:15:21.660 [RPC0] TRACE net.http contrib/epee/include/net/http_protocol_handler.inl:604 Content-Type: application/json
dd($accounts = $result['subaddress_accounts']);
returns:
array:1 [
0 => array:6 [
"account_index" => 7
"balance" => 153457477836
"base_address" => "86yAuY8fnCUHHbJaUVW37MTpuqwgv6QMuRd3YsVhSRN9R9cRkjcBdWXFECBS******************"
"label" => ""
"tag" => "d289d97a-59ce-43bd-bf8d-7316d68568be"
"unlocked_balance" => 153457477836
]
]
Or as a var_dump on var_dump($result = $this->monerod->get_accounts($accountTag)); returns:
array(3) {
["subaddress_accounts"]=>
array(1) {
[0]=>
array(6) {
["account_index"]=>
int(7)
["balance"]=>
int(153457477836)
["base_address"]=>
string(95) "86yAuY8fnCUHHbJaUVW37MTpuqwgv6QMuRd3YsVhSRN9R9cRkjcBdWXFECBS******************"
["label"]=>
string(0) ""
["tag"]=>
string(36) "d289d97a-59ce-43bd-bf8d-7316d68568be"
["unlocked_balance"]=>
int(153457477836)
}
}
["total_balance"]=>
int(153457477836)
["total_unlocked_balance"]=>
int(153457477836)
}
$this->monerod->transfer((dd($amount*1.000000000000)), $address, $accountIndexes);
returns:
0.00654
Hi, thanks for getting in touch. I've edited a little bit the issue so it's clearer for us and it's easily to read. I'm guessing what the issue might be: how do you call transfer()
method from Wallet RPC Library?
public function transfer($amount, $address = '', $payment_id = '', $mixin = 10, $account_index = 0, $subaddr_indices = '', $priority = 2, $unlock_time = 0, $do_not_relay = false, $ringsize = 16)
@serhack sorry about the messy formatting from me, thanks for correcting it. Basically issue is that transfer doesn't go through when I'm using an index number other than the primary (0), like in this instance I'm trying to do transfer from index 7. And looking in rpc-wallet logs it has incorrect available = 0.000000000000 balance for the selected index number, the balance is actually 0.15346
I guess you should use $subaddr_indices
since you're trying to send from a subaddress.
Argh right. I'll try with adding $subaddr_indices
and see if that works. Thank you for helping.