BlueWallet / LndHub

Wrapper for Lightning Network Daemon. It provides separate accounts for end-users
http://LndHub.io
MIT License
778 stars 197 forks source link

On-chain funds are missing from user balance (code disabled) #331

Open raucao opened 2 years ago

raucao commented 2 years ago

I was wondering why my on-chain refill from Blue Wallet didn't show up in my lndhub account balance. Didn't have to go far to find out that the code is just disabled with a return and a "TODO" comment to re-activate it.

As there's no issue for this, I'm creating one. Maybe one of the core developers could let us know why it's disabled, and what needs to be done in order to remove the return statement again?

https://github.com/BlueWallet/LndHub/blob/9563cb97142bdf52347745459d1755d281928c91/class/User.js#L506-L508

Edit: simply removing the line results in the following exception when calculating the balance:

listtransactions error: Error: {"result":null,"error":{"code":-18,"message":"Requested wallet does not exist or is not loaded"},"id":"a7fa1613-b9e8-4aaf-b817-7c7deafad634"}
    at IncomingMessage.<anonymous> (/opt/lndhub/node_modules/jayson/lib/client/http.js:78:23)
    at IncomingMessage.emit (events.js:326:22)
    at IncomingMessage.EventEmitter.emit (domain.js:483:12)
    at endReadableNT (_stream_readable.js:1241:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  code: 500
}
xraid commented 2 years ago

depending how You deployed LndHub on what kind of distro, the config is pointing to a bitcoind wallet that for ex. Umbrel and the like do not have initialized and therefore error, most "user" nodes only use and have need for the LND wallet but for BIG deployments as for ex. lndhub.io, it would offload address lookup to bitcoind direct instead using LND for address lockup ? and changes been made to not use that function any more for some or other reason.

so lets go back to that You do not se Your tx in BlueWallet or in LND ?

raucao commented 2 years ago

Thanks. I don't quite see how what you're saying is relevant to commenting the function and thus not accounting for on-chain balances altogeher, no matter the on-chain wallet backend.

so lets go back to that You do not se Your tx in BlueWallet or in LND ?

Blue Wallet is irrelevant to this issue. The tx is visible in LND, but not accounting for the user balance in the lndhub API.

xraid commented 2 years ago

when You enable the disabled function it says :

"Requested wallet does not exist or is not loaded"

and i tried explain to You depending on Your distro and configuration it might not have a initialized bitcoind wallet but are only using the LND wallet.

xraid commented 2 years ago

the user account wallet(card) will have a bitcoin address You can get by :

LndHub-URL/getbtc header { content-type: application/json, authorization: Bearer access_token }

LndHub-URL/getbalance header { content-type: application/json, authorization: Bearer access_token }

will return amount sats in paid invoices and tx of bitcoind address shown in the user account wallet(card)

so Your refill should reflect in amount sats in associated account shown in the user account wallet(card)

xraid commented 2 years ago

and if You use :

LndHub-URL/gettxs header { content-type: application/json, authorization: Bearer access_token }

You will see tx´s for the associated bitcoin address

raucao commented 2 years ago

My entire issue is about the associated bitcoin address's incoming transactions not showing up in the balance.

Javihache commented 2 years ago

My entire issue is about the associated bitcoin address's incoming transactions not showing up in the balance.

I have the exact same problem and none of the answers of xraid made any smarter as to what might be going on. @raucao did you manage to solve the issue? I am sending on-chain using BlueWallet trying to top up a newly created lndhub lightning wallet and it's no updating. The LND on-chain wallet receives the transaction but LNDhub cannot see it. I get the same error in the logs: listtransactions error: { Error: {"result":null,"error":{"code":-32601,"message":"Method not found"},

xraid commented 2 years ago

in Your config.js can You comment out : // bitcoind: { // rpc: 'http://login:password@1.1.1.1:8332/wallet/wallet.dat', // }, restart and report back

raucao commented 2 years ago

@Javihache I'm not sure what @xraid thinks is happening, but those replies are not addressing the issue I reported. Nothing you change in the config can magically remove a return statement in the code.

xraid commented 2 years ago

@raucao hehe and You would know

Overtorment commented 2 years ago

i checked the code, and accountForPosibleTxids() is deprecated and should be deleted

Overtorment commented 2 years ago

error "Requested wallet does not exist or is not loaded" suggests that bitcoind is misconfigured. for a very basic usage scenario, you dont need to use bitcoind with LNDHUB, as it wil just fetch onchain data from LND.

raucao commented 2 years ago

Thanks.

i checked the code, and accountForPosibleTxids() is deprecated and should be deleted

What does that mean exactly for on-chain balance accounting? And where is that documented? We're simply trying to top up accounts with BlueWallet, and there's no error message anywhere, until you remove that undocumented return statement.

error "Requested wallet does not exist or is not loaded" suggests that bitcoind is misconfigured. for a very basic usage scenario, you dont need to use bitcoind with LNDHUB, as it wil just fetch onchain data from LND.

If it's misconfigured, then why does BlueWallet show us valid LND on-chain addresses, which we can successfully receive money on that can then be used to open channels?

The answers to these questions would be helpful for fixing the problem for everyone running into it. However, as it is, the released version simply ignores incoming transactions to the on-chain address that is generated from the other endpoint, without telling the user (i.e. provider) why.

raucao commented 2 years ago

We use this config line from the release's code, just with a valid username, password and localhost IP:

https://github.com/BlueWallet/LndHub/blob/64adcfc279484c984e511d9b2a376a790ffb2e9e/config.js#L8

(The values we use mirror exactly LND's own [bitcoind] RPC config.)

Overtorment commented 2 years ago

lndhub takes an onchain address from lnd, and if bitcoind is configured, registers it in bitcoind so its tracked and we can fetch related transactions from bitcoind. if bitcoind is not configured, we fallback to checking onchain transactions from lnd (which uses neutrino). so, your onchain coins always land on lnd successfully, its just a matter of seeing those transactions or not.

relevant code: class/User.js:406

Overtorment commented 2 years ago

to configure your bitcoind, look into why it didnt load default wallet, or maybe your default wallet is called differently or smth. i rarely touch this part so not super familiar with it.

again, if you dont plan to switch lnd on-the-fly as a failover for better service availability, its better to just remove bitcoind configuration and rely on lnd here.

raucao commented 2 years ago

Thanks. There is nothing wrong with the default wallet of that bitcoind node per se. I can use it via bitcoin-cli, for example to list transactions with it. I guess it could still be an issue with the RPC URL in the example, but haven't looked into it further.

Removing the bitcoind config entirely works. (However, it still requires removing the return statement that is marked as TODO in the released code, of course.)