synonymdev / react-native-ldk

React Native LDK
MIT License
51 stars 16 forks source link

Channels opened from LND to LDK remain inactive and payments fail #48

Closed tanx closed 2 years ago

tanx commented 2 years ago

When opening channels from my regtest LND nodes to my iOS node the channels remain inactive. I've tried to mine blocks and update graphs in polar but not sure what the issue is:

lnd@alice:/$ lncli listchannels
{
    "channels": [
        {
            "active": false,
            "remote_pubkey": "0219b5fe26d76181a47294b85c2e8c5deebbb5a6aa21c05c35941800684f73309c",
            "channel_point": "49067f5bd49c7bb311b22a86d16bcc38684002627d65e0908124cefa185e9ade:0",
            "chan_id": "188016488415232",
            "capacity": "100000",
            "local_balance": "40950",
            "remote_balance": "50000",

When alice tries to pay an invoice generated by the LDK wallet the payments fails:

lnd@alice:/$ lncli payinvoice lnbcrt1u1p3ntfjxdqdwpshjmt9wpk85np4qgvmtl3x6ascrfrjjju9ct5vthhthddx4gsuqhp4jsvqq6z0wvcfcpp53phu0udtuayk5qe64cugwyk3840krcvkh5j6tg99lxln9r9m0g8qsp5exgtdyhw6qkrwe857q6rmvnc6ea2l8zrj0lxzf23yh62g0gcc5vq9qyysgqcqpcxqy7s3lacpywuc9xgdext8xrvscah426nmk97wvnl2vygvep5ns4ryn5xss8sdwt53svm08vq36t6f8g0wsaq8npdw8ejqf5anl5xgvd9pcksgpn93hnz
Payment hash: 886fc7f1abe7496a033aae388712d13d5f61e196bd25a5a0a5f9bf328cbb7a0e
Description: paymeplz
Amount (in satoshis): 100
Fee limit (in satoshis): 100
Destination: 0219b5fe26d76181a47294b85c2e8c5deebbb5a6aa21c05c35941800684f73309c
Confirm payment (yes/no): yes
+------------+--------------+--------------+--------------+-----+----------+----------+-------+
| HTLC_STATE | ATTEMPT_TIME | RESOLVE_TIME | RECEIVER_AMT | FEE | TIMELOCK | CHAN_OUT | ROUTE |
+------------+--------------+--------------+--------------+-----+----------+----------+-------+
+------------+--------------+--------------+--------------+-----+----------+----------+-------+
Amount + fee:   0 + 0 sat
Payment hash:   886fc7f1abe7496a033aae388712d13d5f61e196bd25a5a0a5f9bf328cbb7a0e
Payment status: FAILED, reason: FAILURE_REASON_INSUFFICIENT_BALANCE
[lncli] FAILED

These are the logs from alice:

2022-09-28 19:41:01.676 [WRN] CRTR: Failed to find route for payment 85899248aa8aa9b2c43e41a7a102bd81ba0cb7a08023819da7744a108b552f9e: insufficient local balance
2022-09-28 19:41:01.694 [ERR] CRTR: Payment 85899248aa8aa9b2c43e41a7a102bd81ba0cb7a08023819da7744a108b552f9e failed: insufficient_balance

Have you experienced similar issues on regtest? Thanks

Jasonvdb commented 2 years ago

In the simulator can you tap the list channels button and post output or screenshot here?

tanx commented 2 years ago

Simulator Screen Shot - iPhone 14 - 2022-09-29 at 21 59 47

Simulator Screen Shot - iPhone 14 - 2022-09-29 at 22 03 26

coreyphillips commented 2 years ago

Does the channel meet the confirmations_required value of 6? If below this value, you should be able to mine 6 or more blocks in Polar, tap "Sync LDK", "Add Peers" and then try again. After mining these blocks and syncing you should also see the is_usable value returned from "List Channels" switch to true.

tanx commented 2 years ago

Does the channel meet the confirmations_required value of 6?

Yes, I've mined over 100 blocks in polar after opening the channel.

If below this value, you should be able to mine 6 or more blocks in Polar, tap "Sync LDK", "Add Peers" and then try again. After mining these blocks and syncing you should also see the is_usable value returned from "List Channels" switch to true.

I tried this as well and is_usable is still false. To verify... does this turn true on your machine? Do you test on the iOS simulator or physical iPhone device? Thanks

Jasonvdb commented 2 years ago

@tanx mind sending uploading all the logs. A new file is created for every session so just look in the terminal for LDK logs writing to ... Open that dir and upload all the files so we can check the logs for when the channel was opened/confirmed.

tanx commented 2 years ago

So I fixed this. Looks like I introduced a bug on the JS side in my app. So my bad. I resolved it and can now send and receive lightning invoices. We can close this issue. Thank you