nervosnetwork / fiber

21 stars 11 forks source link

[get_invoice] Response is too big when new_invoice description too big #312

Closed gpBlockchain closed 5 days ago

gpBlockchain commented 1 week ago
  1. new_invoice(description="5824180 length")
  2. get_invoice return Response is too big

so, should we limit the description length?

curl --location 'http://127.0.0.1:8228' --header 'Content-Type: application/json' --data '{
    "id": 42,
    "jsonrpc": "2.0",
    "method": "get_payment",
    "params": [
        {
            "payment_hash": "0x2dae50bddc0f362fff0fb93fd12a0b3b98e71dcc888aecf918f1ef88c6c1527c"
        }
    ]
}'

{"jsonrpc":"2.0","result":{"payment_hash":"0x2dae50bddc0f362fff0fb93fd12a0b3b98e71dcc888aecf918f1ef88c6c1527c","status":"Success","created_at":"0x1932f3a5923","last_updated_at":"0x626f07c72b042","failed_error":null},"id":42}%         guopenglin@192 ~ % curl --location 'http://127.0.0.1:8229' --header 'Content-Type: application/json' --data '{
    "id": 42,
    "jsonrpc": "2.0",
    "method": "get_invoice",
    "params": [
        {
            "payment_hash": "0x2dae50bddc0f362fff0fb93fd12a0b3b98e71dcc888aecf918f1ef88c6c1527c"
        }
    ]
}'
{"jsonrpc":"2.0","error":{"code":-32008,"message":"Response is too big","data":"Exceeded max limit of 10485760"},"id":42}
chenyukang commented 1 week ago

we should set a limit for the length of this description, from bolts: https://github.com/lightning/bolts/blob/master/11-payment-encoding.md

h (23): data_length 52. 256-bit description of purpose of payment (SHA256). 
This is used to commit to an associated description that is over 639 bytes, 
but the transport mechanism for the description in that case is transport specific and not defined here.

I will set a 639 as limit.