RGB-Tools / rgb-lightning-node

MIT License
17 stars 19 forks source link

send payment #28

Closed sinobee closed 4 months ago

sinobee commented 4 months ago

Steps I have taken:

Issue asset /issueassetlightning Open channel /openchannel Create invoice /lninvoice Call the send payment API using the invoice Close the channel Everything works perfectly, but the asset amounts are not visible in the asset balance when I call the assetbalance API, even though I mined 6 blocks.

nicbus commented 4 months ago

Hi, what you have described is the behavior of the payment test so that's expected to work.

Can you please confirm the test is working by running cargo test payment?

A couple details:

Please report the logs of the operations you do, so hopefully we can better understand what might be going wrong.

sinobee commented 4 months ago

Hi, what you have described is the behavior of the payment test so that's expected to work.

Can you please confirm the test is working by running cargo test payment?

A couple details:

  • the issue API is called /issueasset
  • did you close the channel cooperatively of did you force-close it?

Please report the logs of the operations you do, so hopefully we can better understand what might be going wrong.

Answers to your questions:

Q1: Can you please confirm the test is working by running cargo test payment?

A1: It is working, but I do not see any logs; it just shows "ok" or something similar.

Q2: The API issue is called /issueasset.

A2: Yes, I called the API before opening the channel.

Q3: Did you close the channel cooperatively, or did you force-close it?

A3: It was closed cooperatively, not forced.

Node 1 log : https://drive.google.com/file/d/1DrdTBFDzjuV32z11opDYnVuZFwUcSmqP/view?usp=sharing

Node 2 log : https://drive.google.com/file/d/1Zv_kJSQDOXujBtPZmgsqsVXAjHyCQXSI/view?usp=sharing

Let me explain my steps in detail, and I also created a Postman collection to ensure the steps are always correct.

Postman colletion : https://drive.google.com/file/d/1Va8zWC1fqAvQzhzrIzWUmCwmMPj10bZL/view?usp=sharing

I am running two LND nodes using the following command:

command 1:

rgb-lightning-node user:password@localhost:18443 dataldk0/ \
    --daemon-listening-port 3001 --ldk-peer-listening-port 9735 --network regtest

command 2 :

rgb-lightning-node user:password@localhost:18443 dataldk1/ \
    --daemon-listening-port 3002 --ldk-peer-listening-port 9736 --network regtest

This node ran successfully without any issues; after that, I took this step: let me explain all steps which i taken :

  1. node 1: /init

  2. node 2: /init

  3. node 1: /unlock

  4. node 2: /unlock

  5. node 1: /address

  6. node 2: /address

  7. node 1(address): I funded the address using the regtest.sh sendtoaddress command.

  8. node 2(address) : I funded the address using the regtest.sh sendtoaddress command.

  9. I mined 1 block using the regtest.sh script's mine method ("mine 1 block").

  10. node 1 : /createutxos (10 utxos)

  11. node 2 : /createutxos (10 utxos)

  12. I mined 1 block using the regtest.sh script's mine method ("mine 1 block").

  13. node 1 : /issueasset

  14. node 1 : /openchannel param :

    {
    "peer_pubkey_and_addr": "034792151e71c891c2721d4c949e6499f1223daa662b43778c21bc5e2ebc5fc838@localhost:9736",
    "capacity_sat": 100000,
    "push_msat": 3500000,
    "asset_amount": 600,
    "asset_id": "rgb:251Jnui-PhgiRTcH6-DSGjsweut-U32ZEt8Vb-L9T89KJpV-SudVKWP",
    "public": true,
    "with_anchors": true,
    "fee_base_msat": 1000,
    "fee_proportional_millionths": 0
    }

resnponse :

{
    "temporary_channel_id": "3d5b8cb73c6387b78c60e7e54f52a2d1aefd2ed5c860b709c6c95018de74da7e"
}
  1. node 2 : /lninvoice params :
    {
    "amt_msat": 3000000,
    "expiry_sec": 900,
    "asset_id": "{{ASSET_ID}}",
    "asset_amount": 100
    }

response :

{
    "invoice": "lnbcrt30u1pnz53e7dqud3jxktt5w46x7unfv9kz6mn0v3jsnp4qdrey9g7w8yfrsnjr4xff8nyn8cjy0d2vc45xauvyx79ut4utlyrspp5j8wpgnt8lfn7fsy84zcqa6t56pa4sd9s6vrak5lk8vql3e0mrc6ssp55sauxh2jp2sthff2wkcg0lcvta6449s6842mary867fnz36cht9s9qyysgqcqpcxqzuylzlwfnkyw3jx5c55mn4dyk4q6r8d9f9gc6gxck5g568dfehwet4wsk42vejtfzhgwzkvgk5cw258qu5kjns2ck4xaty2e94w5q7qzryrzjqtmnag8stgyy2l90s24amr8e80rv48pc6smkfdewt4jdrv2z3xkvkqqqqyqq3kqqqqqqqqlgqqqqqqqqfq5tuhtmkg6g4xkk4dk2rrs4krsjsg4j3s9m8e3vqnqatxdmeg8cqq9h2hxe6kh92h5n6kf64ta3rkljlxzu6cj5d34xh2p0avdhp8fdgpna3my5"
}

16 . node 1 and node 2 : /listpayments

response :

{
    "payments": [
        {
            "amt_msat": 3000000,
            "asset_amount": null,
            "asset_id": null,
            "payment_hash": "91dc144d67fa67e4c087a8b00ee974d07b5834b0d307db53f63b01f8e5fb1e35",
            "inbound": false,
            "status": "Succeeded"
        }
    ]
}
  1. node 1 close channel :
    {
    "channel_id": "f6cd8af2699c840939dff975bceb3faab72fdde5aca3377a9989e957b346142f",
    "peer_pubkey": "034792151e71c891c2721d4c949e6499f1223daa662b43778c21bc5e2ebc5fc838",
    "force": false
    }

    18 . again mined 6 block because : cooperatively close

19 There is an issue where both Node 1 and Node 2 respond when the /assetbalance endpoint is called :

node 1 res :

{
    "settled": 400,
    "future": 400,
    "spendable": 400,
    "offchain_outbound": 0,
    "offchain_inbound": 0
}
node 2 res : {
    "settled": 0,
    "future": 0,
    "spendable": 0,
    "offchain_outbound": 0,
    "offchain_inbound": 0
}

I suppose node 1 should have 900 and node 2 should have 100, but it looks like the assets were not transferred successfully.

zoedberg commented 4 months ago

At step 16 you reported

{
    "payments": [
        {
            "amt_msat": 3000000,
            "asset_amount": null,
            "asset_id": null,
            "payment_hash": "91dc144d67fa67e4c087a8b00ee974d07b5834b0d307db53f63b01f8e5fb1e35",
            "inbound": false,
            "status": "Succeeded"
        }
    ]
}

showing a payment that is in the correct status (Succeeded) but has no information about the transferred asset. So this is a bug and I fixed that here: https://github.com/RGB-Tools/rust-lightning/commit/dacd467587a607a58209b047db15b8765f7e75fd (I've also improved the checks of the payment test in order to avoid future regressions, see https://github.com/RGB-Tools/rgb-lightning-node/commit/b9a44360ec03a5ab34701175c5349d309710e168)

I suppose node 1 should have 900 and node 2 should have 100, but it looks like the assets were not transferred successfully.

Assets were being transferred correctly but information about RGB transfer was getting lost. The spendable balance of node 1 is indicating that the assets from channel closure haven't been claimed yet. There is a periodic sweep task in RLN that runs once a day to claim on-chain funds after channel closures. When tests execute we set this time to 5 seconds (look for interval_sweep_secs in the code). Therefore I don't think there's a bug on channel closure. Maybe in the future we will allow users to specify a different interval for this task but for now if you just want to play with the node on regtest/testnet you can run the node with cargo run --profile test (this way the sweep task will execute every 5 seconds).

Closing this, feel free to re-open it if you don't think this has been solved