Closed Keith-CY closed 5 days ago
add_tlc is a low level rpc, you should use send_payment rpc instead.
could you please add the details of parameters for each step? so that we can reproduce it.
because we have test case for this scenario, I'm not sure about the difference of your request.
could you please add the details of parameters for each step? so that we can reproduce it.
because we have test case for this scenario, I'm not sure about the difference of your request.
Sure, but all steps except the add tlc
were done by a local service which I'm working on, the data format could be slightly different.
## open channel
curl -X "POST" "http://127.0.0.1:3000/channels" \
-H 'Content-Type: application/json; charset=utf-8' \
-d $'{
"peer_id": "Qmcg7Du8ktQuN8pPrd4w5hni4x6dxjrp6R67LKkUK63SaV",
"funding_amount": "0x3c5986200"
}'
got response
{
"code": 0,
"message": "Open channel with tmp id 0x1b86e397b9882c21ee0e3d6d8e6d0166f06f32e008fa97609d0c0470fd046d29"
}
## new invoice
curl -X "POST" "http://localhost:3000/invoices" \
-H 'Content-Type: application/json; charset=utf-8' \
-d $'{
"amount": "62000000",
"currency": "Fibt",
"description": "test for api service",
"payment_preimage": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1",
"hash_algorithm": "sha256"
}'
got response
{
"code": 0,
"result": {
"invoice_address": "fibt620000001p49t2j4c5ujgfw0pnm6vklu9dxxa2pq7ygz5nvpwvrtlsd7mcl3rx7828a099ndxh9vld2fdlzh7s6rz8h33c6sf0llmhynqqp74hnpsrswm8zx5vasf4kmx3ux2h57nf9c39j59k2cazxha8476ev9hhelghl4de8fyycstt6r7p6sangu9llzm8axayvjnqyhwx8uplsp5k6905aw0csn0lruh834zq6xfhnrjq66lepvmjqpvfu7zgzj0vl895s6avdyg8lgpn9sc8pjhpxt5tfvqgwfl93njal5yu4vw2xmpe0lt3kt7yjchkjcrsfmfwmgqp3ej6gw",
"invoice": {
"currency": "Fibt",
"amount": "0x3b20b80",
"signature": "1a060917130312001a1a1f19010c1b1200010c091c1e020802120f0c1f070514101a1d0c0d0408071f0801130510180701121701060b140b090c00080e091f051113121d1f14041c150c0e0a061b01190f1f0b11160b1e041218171612180310091b090e1b080001",
"data": {
"timestamp": "0x19347b687d4",
"payment_hash": "0xaa09444ba38bb8a19d358050d6d6ee6155bc274c7ec817c6c73b3e492c6195a3",
"attrs": [
{
"Description": "test for api service"
},
{
"HashAlgorithm": "sha256"
},
{
"PayeePublicKey": "03e4ee65d5bcd71adfc5fd3e3a44b022f0009f34d5441807cbf22e2edb87104fa9"
}
]
}
}
}
}
## Add Tlc
curl -X "POST" "http://127.0.0.1:8227/" \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d $'{
"id": 1,
"jsonrpc": "2.0",
"method": "add_tlc",
"params": [
{
"channel_id": "0x708c0cb9c8b2de64c608fd0443f9e3dfcd37b3d9d77bffbfe8db9e21a6c251a5",
"amount": "0x3b20b00",
"payment_hash": "0xaa09444ba38bb8a19d358050d6d6ee6155bc274c7ec817c6c73b3e492c6195a3",
"hash_algorithm": "sha256",
"expiry": "0x28"
}
]
}'
got error
{
"jsonrpc": "2.0",
"error": {
"code": -32000,
"message": "TlcErrPacket",
"data": {
"channel_id": "0x708c0cb9c8b2de64c608fd0443f9e3dfcd37b3d9d77bffbfe8db9e21a6c251a5",
"amount": "0x3b20b00",
"payment_hash": "0xaa09444ba38bb8a19d358050d6d6ee6155bc274c7ec817c6c73b3e492c6195a3",
"expiry": "0x28",
"hash_algorithm": "sha256"
}
},
"id": 1
}
changed the endpoint, change the amount(it should not matter)
## Add Tlc
curl -X "POST" "http://127.0.0.1:8227/" \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d $'{
"id": 1,
"jsonrpc": "2.0",
"method": "add_tlc",
"params": [
{
"channel_id": "0x708c0cb9c8b2de64c608fd0443f9e3dfcd37b3d9d77bffbfe8db9e21a6c251a5",
"amount": "0x3b20b80",
"payment_hash": "0xaa09444ba38bb8a19d358050d6d6ee6155bc274c7ec817c6c73b3e492c6195a3",
"hash_algorithm": "sha256",
"expiry": "0x28"
}
]
}'
got a response
{
"jsonrpc": "2.0",
"result": {
"tlc_id": "0x0"
},
"id": 1
}
## Get Invoice
curl -X "POST" "http://127.0.0.1:8227/" \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d $'{
"id": 1,
"jsonrpc": "2.0",
"method": "get_invoice",
"params": [
{
"payment_hash": "0xaa09444ba38bb8a19d358050d6d6ee6155bc274c7ec817c6c73b3e492c6195a3"
}
]
}'
got response
{
"jsonrpc": "2.0",
"result": {
"invoice_address": "fibt620000001p49t2j4c5ujgfw0pnm6vklu9dxxa2pq7ygz5nvpwvrtlsd7mcl3rx7828a099ndxh9vld2fdlzh7s6rz8h33c6sf0llmhynqqp74hnpsrswm8zx5vasf4kmx3ux2h57nf9c39j59k2cazxha8476ev9hhelghl4de8fyycstt6r7p6sangu9llzm8axayvjnqyhwx8uplsp5k6905aw0csn0lruh834zq6xfhnrjq66lepvmjqpvfu7zgzj0vl895s6avdyg8lgpn9sc8pjhpxt5tfvqgwfl93njal5yu4vw2xmpe0lt3kt7yjchkjcrsfmfwmgqp3ej6gw",
"invoice": {
"currency": "Fibt",
"amount": "0x3b20b80",
"signature": "1a060917130312001a1a1f19010c1b1200010c091c1e020802120f0c1f070514101a1d0c0d0408071f0801130510180701121701060b140b090c00080e091f051113121d1f14041c150c0e0a061b01190f1f0b11160b1e041218171612180310091b090e1b080001",
"data": {
"timestamp": "0x19347b687d4",
"payment_hash": "0xaa09444ba38bb8a19d358050d6d6ee6155bc274c7ec817c6c73b3e492c6195a3",
"attrs": [
{
"Description": "test for api service"
},
{
"HashAlgorithm": "sha256"
},
{
"PayeePublicKey": "03e4ee65d5bcd71adfc5fd3e3a44b022f0009f34d5441807cbf22e2edb87104fa9"
}
]
}
},
"status": "Open"
},
"id": 1
}
The status is still Open
My bad, some more details will be added
could you please upload the logs from node B, especially for the part of TlcErrPacket
.
could you please upload the logs from node B, especially for the part of
TlcErrPacket
.
I cleared fiber/store
of both nodes and restarted them, went through the steps again and found the following message in node 2
2024-11-20T05:00:42.654392Z INFO fnn::fiber::network: send command to channel: ChannelCommandWithId { channel_id: Hash256(0x13bdf3a88962f1310aff73f8086d8cf073895529a7d9f068043f8045af15b78d), command: AddTlc(AddTlcCommand { amount: 62000000, preimage: None, payment_hash: Some(Hash256(0x4d12332c7f14cdaafa2b617b50feec749250000a8d75662c72c8931374176fca)), expiry: 40, hash_algorithm: Sha256, onion_packet: [], previous_tlc: None }, RpcReplyPort { port: Sender { inner: Some(Inner { state: State { is_complete: false, is_closed: false, is_rx_task_set: true, is_tx_task_set: false } }) }, timeout: None }) }
at src/fiber/network.rs:1385
in ractor::actor::Actor with id: "0.2", name: "Network Qmcg7Du8ktQuN8pPrd4w5hni4x6dxjrp6R67LKkUK63SaV"
2024-11-20T05:00:42.654515Z ERROR fnn::fiber::channel: Error while processing channel command: InvalidParameter("Adding tlc Offered(0) with amount 62000000 exceeds local balance 0")
at src/fiber/channel.rs:1860
in ractor::actor::Actor with id: "0.6"
2024-11-20T05:00:42.654985Z ERROR fnn::rpc::channel: channel request params AddTlcParams { channel_id: Hash256(0x13bdf3a88962f1310aff73f8086d8cf073895529a7d9f068043f8045af15b78d), amount: 62000000, payment_hash: Hash256(0x4d12332c7f14cdaafa2b617b50feec749250000a8d75662c72c8931374176fca), expiry: 40, hash_algorithm: Some(Sha256) } => error: "TlcErrPacket"
at src/rpc/channel.rs:519
node 2 had 0 balance
I used A to pay the invoice, the offered balance updated but the status of invoice was still open
add_tlc is a low level rpc, you should use send_payment rpc instead.
I will use send_payment
From the log of B Adding tlc Offered(0) with amount 62000000 exceeds local balance 0
, seems because the paying node don't have enough balance for AddTlc.
please note the balances of channel, for example if you send OpenChannel request with amount of 100 to A, trying to create a channel with B, B may auto accept the channel, in this state, the balance of this channel is (A: 100, B: 0). Then if you create a invoice from A, B can not pay it since it's balance is 0.
You sent the same request to A, and make A pays to B, seems weird. If you use SendPayment with invoice, it's forbidden to pay A invoice generated by self without allow_self_payment
as true
.
commit: feefe59ba06731ba3b9881f20a16cdb0c34c3739
Steps:
add tlc
, but got an errormessage: TlcErrPacket
Open
, it's expected to bePaid
Thus there were 2 issues