Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

channel funding tx fee too low #1194

Closed
fixone opened this issue Mar 9, 2018 · 27 comments
Closed

channel funding tx fee too low #1194

fixone opened this issue Mar 9, 2018 · 27 comments

Comments

@fixone
Copy link
Contributor

fixone commented Mar 9, 2018

"version" : "v0.5.2-2016-11-21-2262-gd363a68"

any channel I try to fund ends up with 66: min relay fee not met? and the log shows

2018-03-09T07:51:40.117Z lightningd(2550): Owning output 0 49543 (SEGWIT) txid ecce68e9f6f03882c8ea7ed389b1f9db7e3c54c6812d4a7ad10320064297aad4
2018-03-09T07:51:40.117Z lightningd(2550): 	 (tx ecce68e9f6f03882c8ea7ed389b1f9db7e3c54c6812d4a7ad10320064297aad4)
2018-03-09T07:51:40.117Z lightningd(2550): sendrawtransaction: 02000000000101158bf6c859e74dfb8b23b583944fb055ffbbfdbd5027f4df4f98168232909d320000000000ffffffff0287c10000000000001600145231c938e2213be703e3b3926e4fda4c1b68ce1ef07e0e000000000022002087d6c3b1e3b2bc251ee0c79d09ae8e85c1a7e05ec72314e281dc21877928ee3802473044022044a2a9a63a34d73bec8ec3873b1f31b8177b07a9a71c630df04ec679c63b1d2b02207ce83dcb73ae6dbcab8d9a4f0893f4439e5447c523b1a3745871e613cabeb215012102d263d904d10206f426099b6f4bd839b221ca2743f5e40b56871726aa7f15037900000000
2018-03-09T07:51:40.118Z lightningd(2550): Client: Received message 9 from client
2018-03-09T07:51:40.131Z lightningd(2550): lightning_channeld-03bf2b602bc3d9dabc6d9172808a0bbe970120ff89be2343ac251980ca8602ffe6 chan #92: pid 841, msgfd 54
2018-03-09T07:51:40.131Z lightningd(2550): 03bf2b602bc3d9dabc6d9172808a0bbe970120ff89be2343ac251980ca8602ffe6 chan #92: Waiting for funding confirmations
2018-03-09T07:51:40.131Z lightningd(2550): 03bf2b602bc3d9dabc6d9172808a0bbe970120ff89be2343ac251980ca8602ffe6 chan #92: Ignoring fee limits!
2018-03-09T07:51:40.136Z lightningd(2550):jcon fd 39: Success
2018-03-09T07:51:40.138Z lightningd(2550): sendrawtx exit 26, gave error code: -26?error message:?66: min relay fee not met?
2018-03-09T07:51:40.138Z lightningd(2550): 03bf2b602bc3d9dabc6d9172808a0bbe970120ff89be2343ac251980ca8602ffe6 chan #92: Peer internal error CHANNELD_AWAITING_LOCKIN: Funding broadcast exited with 26: error code: -26?error message:?66: min relay fee not met?
2018-03-09T07:51:40.138Z lightningd(2550): 03bf2b602bc3d9dabc6d9172808a0bbe970120ff89be2343ac251980ca8602ffe6 chan #92: Peer permanent failure in CHANNELD_AWAITING_LOCKIN: Internal error: Funding broadcast exited with 26: error code: -26?error message:?66: min relay fee not met?
2018-03-09T07:51:40.139Z lightningd(2550): lightning_channeld-03bf2b602bc3d9dabc6d9172808a0bbe970120ff89be2343ac251980ca8602ffe6 chan #92: Status closed, but not exited. Killing
2018-03-09T07:51:40.139Z lightningd(2550): 	 (tx 652c6b4aef3307a2eddc7a8364e2c725b7440a9a0864fc5b837c112b0123804b)
2018-03-09T07:51:40.140Z lightningd(2550): sendrawtransaction: 02000000000101d4aa9742062003d17a4a2d81c6543c7edbf9b189d37eeac88238f0f6e968ceec01000000006f594780013b7e0e000000000022002074cf1d13ccdb44df0edd2cec13a217ab5a376d80c9874c867ca5fbf82c8184d20400473044022058a94ff73eb444b36c818ae7949bffc65e6bcaee0b10cbfee74405e3292f745d0220086ffd0b11975dd7baf407f056844eead3efa5b3539f6fd9e5c5d0700ec288370148304502210098f4eac42365e95aea3724efa6b503fea798a2361f6525b216c23a459938f48d02204477823e4875f082a3962815c4ebb7f95bb551d50e1019611160f40413b3560201475221021e7e169bac2fbd6d078f4543303451079e3402fde5bec734c7aaf8a72513c4082102c5549c92f4a616a6ea33b149cf6a9876d82134990f4eae764fea0641b52a6da952aee1b93120
2018-03-09T07:51:40.141Z lightning_gossipd(2558): Forgetting remote peer 03bf2b602bc3d9dabc6d9172808a0bbe970120ff89be2343ac251980ca8602ffe6
2018-03-09T07:51:40.146Z lightningd(2550): sendrawtx exit 25, gave error code: -25?error message:?Missing inputs?

my bitcoind is 0.16 and getnetworkinfo shows (relevant info : "relayfee": 1e-05)

{
  "version": 160000,
  "subversion": "/Satoshi:0.16.0/",
  "protocolversion": 70015,
  "localservices": "000000000000040d",
  "localrelay": true,
  "timeoffset": 0,
  "networkactive": true,
  "connections": 15,
  "networks": [
    {
      "name": "ipv4",
      "limited": false,
      "reachable": true,
      "proxy": "",
      "proxy_randomize_credentials": false
    },
    {
      "name": "ipv6",
      "limited": false,
      "reachable": true,
      "proxy": "",
      "proxy_randomize_credentials": false
    },
    {
      "name": "onion",
      "limited": true,
      "reachable": false,
      "proxy": "",
      "proxy_randomize_credentials": false
    }
  ],
  "relayfee": 1e-05,
  "incrementalfee": 1e-05,
  "localaddresses": [
    {
      "address": "188.166.99.121",
      "port": 18333,
      "score": 702
    }
  ],
  "warnings": "Warning: unknown new rules activated (versionbit 28)"
}

is there a way to specify the fee for the funding transaction?

@hkjn
Copy link

hkjn commented Mar 9, 2018

I don't know the answer to your question (and thanks for the report; I believe c-lightning does need to handle this situation better), but as a workaround to get your channel set up you should be able to set minrelaytxfee in your bitcoin.conf to a lower value (or on the commandline), and retransmit the funding tx with bitcoin-cli sendrawtransaction.

@fixone
Copy link
Contributor Author

fixone commented Mar 9, 2018

I don't think that's the only problem, considering that there were several channels opened with the same bitcoind.conf. I wonder if there's any kind of fee estimation and it makes use of the fact that minrelayfee can be obtained from bitcoind and not use a lower one

@cdecker
Copy link
Member

cdecker commented Mar 9, 2018

That's a weird one: according to the decoded message and the output being spent c-lightning is trying to create a transaction with a negative fees (950000 + 49543 - 999695 = -152 satoshi fee). Can you share the output of listfunds?

@fixone
Copy link
Contributor Author

fixone commented Mar 9, 2018

Here it is

lnc listfunds
{ "outputs" :
        [
                { "txid" : "a4c97f71815e3e0c23ff2c89ddec9bdad639ea0855c55cab471a24674761103a", "output" : 0, "value" : 999695, "status" : "confirmed" },
                { "txid" : "edb8fa3c9ad5d25389d972af1483a53027b50315ca505c5097fde4f80f0c6986", "output" : 0, "value" : 999695, "status" : "confirmed" },
                { "txid" : "d596688b2064bd8a917e1119250f0f516b00c5b0d1fd5de4b5b75b1495d593c8", "output" : 0, "value" : 999593, "status" : "confirmed" },
                { "txid" : "73460608c906b1b0dcd0b969443e712073bba96d3930025a1ee6b5c227e3edb4", "output" : 1, "value" : 5584708, "status" : "confirmed" },
                { "txid" : "01d467538773dd061f3e0344ddd31d0d421d65865bc499572559d1c68cd1a6b3", "output" : 1, "value" : 7048935, "status" : "unconfirmed" },
                { "txid" : "a63b07143c7dd712b4021add815132e95400058c036a064662a4e9b16e7fb38a", "output" : 1, "value" : 38802485, "status" : "unconfirmed" },
                { "txid" : "ecce68e9f6f03882c8ea7ed389b1f9db7e3c54c6812d4a7ad10320064297aad4", "output" : 0, "value" : 49543, "status" : "unconfirmed" } ], "channels" :
        [
                { "peer_id" : "033dd7f388fdbf33915c68b548883b899516a8ed7da14ae5eff03ad9f9ab1fe7ad", "short_channel_id" : "1284270:175:0", "channel_sat" : 991979, "channel_total_sat" : 1000000, "funding_txid" : "ec84b4163e6ccf0a0859fb57d441fcb9b99d4abb18dc28fd8d14413cb45a7351" },
                { "peer_id" : "027e92b4fa1988ae5b0d44b87da80ab8875312fdae6631a8896851bc41857e66aa", "short_channel_id" : "1284270:177:0", "channel_sat" : 999647, "channel_total_sat" : 1000000, "funding_txid" : "c590a2cde116c74cd04facd2364ee6b8b9b667b92f56cc52bec5d1b5c724bb87" },
                { "peer_id" : "034fd1f523d694f340f2ee92971a04f837df3e910568222b889ad51b4b826ff361", "short_channel_id" : "1284356:186:0", "channel_sat" : 1000000, "channel_total_sat" : 1000000, "funding_txid" : "96eba683e478c2f1b633f821ad66c067c38b5e0dbe91482aa0eb09752d690617" },
                { "peer_id" : "0215b7a76fba355117f916473509719c5e9c3b57a0092f1395ceeea41f4b03c4f0", "short_channel_id" : "1284585:53:1", "channel_sat" : 0, "channel_total_sat" : 900000, "funding_txid" : "5c17813733cea6ae42204f29d0c0e7cf6164c5d83c75958654018601929174d2" },
                { "peer_id" : "028fd42a3eb383bfb803e49f393fb11786108d879fcd46cdfa5ee283e3b896077b", "short_channel_id" : "1286025:14:0", "channel_sat" : 1000000, "channel_total_sat" : 1000000, "funding_txid" : "9cf727bc8589a9810d2501df350b66aa49fe28f84a522069250510fe0e7fb467" },
                { "peer_id" : "0381302d9733ac244d0480fb6e5f5f9a6042cd79b9c7ac27d019231185a5344272", "short_channel_id" : "1287117:219:1", "channel_sat" : 1000000, "channel_total_sat" : 1000000, "funding_txid" : "db7263953b4d515c87b008bb4c13d50fee816d19db11655957e12fbf5ba842f4" },
                { "peer_id" : "038f80b541c3a9c1bbd54b4b15a379db83221e3fb50d5ffc543cef6d62a7f71631", "short_channel_id" : "1287246:46:0", "channel_sat" : 1000000, "channel_total_sat" : 1000000, "funding_txid" : "500abba55668c8da79a5a10cb75ce4b6de0e62c1312e7f00fdd6021bd1f269b9" },
                { "peer_id" : "03933884aaf1d6b108397e5efe5c86bcf2d8ca8d2f700eda99db9214fc2712b134", "short_channel_id" : "1287246:45:0", "channel_sat" : 993689, "channel_total_sat" : 1000000, "funding_txid" : "3760a425946a3dd43a551964d189a6988f1e915a209009b7eb1b89cbaf03ee9a" },
                { "peer_id" : "03730e691d0b4948e42eff18131ef8d345792219601d36796bf3675ce0e5694f99", "short_channel_id" : "1287344:87:0", "channel_sat" : 1000000, "channel_total_sat" : 1000000, "funding_txid" : "80ac96bfc18c025e2efe4229b9478986c6ea5b0aef76360c0457ec5d4c73f7d5" },
                { "peer_id" : "024c873f489141f6581c78a8af32a6209eb23847ca55c18b4032e6789af1abfcd0", "short_channel_id" : "1287344:99:0", "channel_sat" : 1000000, "channel_total_sat" : 1000000, "funding_txid" : "33bad12d5266daf3fdea77746b0aa58eedab4c8fd03a664ac4058076dc0fc2b1" },
                { "peer_id" : "03f2297213af13b2f61c8881ac96c896d3a5dc53e3a4163d2c594f82d94f8b69a2", "short_channel_id" : "1287344:88:0", "channel_sat" : 1000000, "channel_total_sat" : 1000000, "funding_txid" : "a80a76cfa0406723e9d6fefe90966758f69e369f5aea59e0f7bbb9ecfff5c600" },
                { "peer_id" : "0340b8665eb88e576a8e6ec975ab1aa2aea1568deb7cd2195ccb83473f6e1fbf6d", "short_channel_id" : "1287414:179:0", "channel_sat" : 1000000, "channel_total_sat" : 1000000, "funding_txid" : "cf2686d4a0081eec159369fc025349c331e1ff64fdc327e9485447f69f38a61d" },
                { "peer_id" : "03172377a939b21aadab64943ac82fc54a6600db48812dec9046c78abd78f5a0a2", "short_channel_id" : "1287428:7:0", "channel_sat" : 980000, "channel_total_sat" : 980000, "funding_txid" : "73460608c906b1b0dcd0b969443e712073bba96d3930025a1ee6b5c227e3edb4" } ] }

@cdecker
Copy link
Member

cdecker commented Mar 9, 2018

Sorry, I was hoping to see what c-lightning believes the value of output 1329d90328216984fdff42750bdfdbbff55b04f9483b5238bfb4de759c8f68b15:0 is, but that is marked as spent apparently. Could you do a dev-rescan-outputs which'll get the outputs unstuck, and then listfunds again?

@fixone
Copy link
Contributor Author

fixone commented Mar 9, 2018

After dev-rescan-outputs

lnc listfunds
{ "outputs" :
        [
                { "txid" : "3760a425946a3dd43a551964d189a6988f1e915a209009b7eb1b89cbaf03ee9a", "output" : 1, "value" : 7999087, "status" : "confirmed" },
                { "txid" : "cf2686d4a0081eec159369fc025349c331e1ff64fdc327e9485447f69f38a61d", "output" : 1, "value" : 39752637, "status" : "confirmed" },
                { "txid" : "329d90328216984fdff42750bdfdbbff55b04f9483b5238bfb4de759c8f68b15", "output" : 0, "value" : 999695, "status" : "confirmed" },
                { "txid" : "a4c97f71815e3e0c23ff2c89ddec9bdad639ea0855c55cab471a24674761103a", "output" : 0, "value" : 999695, "status" : "confirmed" },
                { "txid" : "edb8fa3c9ad5d25389d972af1483a53027b50315ca505c5097fde4f80f0c6986", "output" : 0, "value" : 999695, "status" : "confirmed" },
                { "txid" : "d596688b2064bd8a917e1119250f0f516b00c5b0d1fd5de4b5b75b1495d593c8", "output" : 0, "value" : 999593, "status" : "confirmed" },
                { "txid" : "73460608c906b1b0dcd0b969443e712073bba96d3930025a1ee6b5c227e3edb4", "output" : 1, "value" : 5584708, "status" : "confirmed" } ], "channels" :
        [
                { "peer_id" : "033dd7f388fdbf33915c68b548883b899516a8ed7da14ae5eff03ad9f9ab1fe7ad", "short_channel_id" : "1284270:175:0", "channel_sat" : 991979, "channel_total_sat" : 1000000, "funding_txid" : "ec84b4163e6ccf0a0859fb57d441fcb9b99d4abb18dc28fd8d14413cb45a7351" },
                { "peer_id" : "027e92b4fa1988ae5b0d44b87da80ab8875312fdae6631a8896851bc41857e66aa", "short_channel_id" : "1284270:177:0", "channel_sat" : 999647, "channel_total_sat" : 1000000, "funding_txid" : "c590a2cde116c74cd04facd2364ee6b8b9b667b92f56cc52bec5d1b5c724bb87" },
                { "peer_id" : "034fd1f523d694f340f2ee92971a04f837df3e910568222b889ad51b4b826ff361", "short_channel_id" : "1284356:186:0", "channel_sat" : 1000000, "channel_total_sat" : 1000000, "funding_txid" : "96eba683e478c2f1b633f821ad66c067c38b5e0dbe91482aa0eb09752d690617" },
                { "peer_id" : "0215b7a76fba355117f916473509719c5e9c3b57a0092f1395ceeea41f4b03c4f0", "short_channel_id" : "1284585:53:1", "channel_sat" : 0, "channel_total_sat" : 900000, "funding_txid" : "5c17813733cea6ae42204f29d0c0e7cf6164c5d83c75958654018601929174d2" },
                { "peer_id" : "028fd42a3eb383bfb803e49f393fb11786108d879fcd46cdfa5ee283e3b896077b", "short_channel_id" : "1286025:14:0", "channel_sat" : 1000000, "channel_total_sat" : 1000000, "funding_txid" : "9cf727bc8589a9810d2501df350b66aa49fe28f84a522069250510fe0e7fb467" },
                { "peer_id" : "0381302d9733ac244d0480fb6e5f5f9a6042cd79b9c7ac27d019231185a5344272", "short_channel_id" : "1287117:219:1", "channel_sat" : 1000000, "channel_total_sat" : 1000000, "funding_txid" : "db7263953b4d515c87b008bb4c13d50fee816d19db11655957e12fbf5ba842f4" },
                { "peer_id" : "038f80b541c3a9c1bbd54b4b15a379db83221e3fb50d5ffc543cef6d62a7f71631", "short_channel_id" : "1287246:46:0", "channel_sat" : 1000000, "channel_total_sat" : 1000000, "funding_txid" : "500abba55668c8da79a5a10cb75ce4b6de0e62c1312e7f00fdd6021bd1f269b9" },
                { "peer_id" : "03933884aaf1d6b108397e5efe5c86bcf2d8ca8d2f700eda99db9214fc2712b134", "short_channel_id" : "1287246:45:0", "channel_sat" : 993689, "channel_total_sat" : 1000000, "funding_txid" : "3760a425946a3dd43a551964d189a6988f1e915a209009b7eb1b89cbaf03ee9a" },
                { "peer_id" : "03730e691d0b4948e42eff18131ef8d345792219601d36796bf3675ce0e5694f99", "short_channel_id" : "1287344:87:0", "channel_sat" : 1000000, "channel_total_sat" : 1000000, "funding_txid" : "80ac96bfc18c025e2efe4229b9478986c6ea5b0aef76360c0457ec5d4c73f7d5" },
                { "peer_id" : "024c873f489141f6581c78a8af32a6209eb23847ca55c18b4032e6789af1abfcd0", "short_channel_id" : "1287344:99:0", "channel_sat" : 1000000, "channel_total_sat" : 1000000, "funding_txid" : "33bad12d5266daf3fdea77746b0aa58eedab4c8fd03a664ac4058076dc0fc2b1" },
                { "peer_id" : "03f2297213af13b2f61c8881ac96c896d3a5dc53e3a4163d2c594f82d94f8b69a2", "short_channel_id" : "1287344:88:0", "channel_sat" : 1000000, "channel_total_sat" : 1000000, "funding_txid" : "a80a76cfa0406723e9d6fefe90966758f69e369f5aea59e0f7bbb9ecfff5c600" },
                { "peer_id" : "0340b8665eb88e576a8e6ec975ab1aa2aea1568deb7cd2195ccb83473f6e1fbf6d", "short_channel_id" : "1287414:179:0", "channel_sat" : 1000000, "channel_total_sat" : 1000000, "funding_txid" : "cf2686d4a0081eec159369fc025349c331e1ff64fdc327e9485447f69f38a61d" },
                { "peer_id" : "03172377a939b21aadab64943ac82fc54a6600db48812dec9046c78abd78f5a0a2", "short_channel_id" : "1287428:7:0", "channel_sat" : 980000, "channel_total_sat" : 980000, "funding_txid" : "73460608c906b1b0dcd0b969443e712073bba96d3930025a1ee6b5c227e3edb4" } ] }

@cdecker
Copy link
Member

cdecker commented Mar 12, 2018

Hm, also doesn't contain the output I was looking for, maybe it's marked as spent as well?

Could you run the following and share the output?

sqlite3 demo/lightningd.sqlite3 "SELECT hex(prev_out_tx), prev_out_index, status, value FROM outputs"

@fixone
Copy link
Contributor Author

fixone commented Mar 12, 2018

here it is

4724FA5FC48390A6253AD0009D976EFEB983ECD9E45ACEEA61874D70CDEEE41E|0|2|70000000
378665A398C29DA53192215F4B2949F6B853F624EE2A590A56392E366A515586|1|2|59999822
36054D6AE63DC382F9A62EFF5FDB807345E75DFBBCF6E22E3A68425E1D943FF4|1|2|58999668
0188DE85F14AA5E7B1A023C454C9FB509D2C9EA3CA99928FCCC80AF475D2907A|1|2|48999514
81A279C35BB457A0CCE4B07AB746798021DEC0FBF316EDB51E1FD51D0B70CC40|1|2|47999360
51735AB43C41148DFD28DC18BB4A9DB9B9FC41D457FB59080ACF6C3E16B484EC|1|2|46999206
2CB9519EBDDFBB241782E3CBA64184AB48C79307E89F59B7BAA2587E01D7DBE1|1|2|45999052
87BB24C7B5D1C5BE52CC562FB967B6B9B8E64E36D2AC4FD04CC716E1CDA290C5|1|2|44998898
1706692D7509EBA02A4891BE0D5E8BC367C066AD21F833B6F1C278E483A6EB96|1|2|43998743
B8493A71B192F78A84B7519C766562294D4B98EBBD55AA3445EF82D351FC272D|1|2|42998592
8FB6D1AB010419855EA9CFEEC4F96DF61230B0FFCF1D6E5CD5096EE91BF22284|1|2|41998440
243422E14D15704957FF55CACE60538A7E704CC4D903E816F6CAC12ED6B4E28B|1|2|40998288
12C04C081895359129B2CF94E6A77EE35F9EF7659A7D2F64BD9B24A044817923|0|2|9999700
A8041FFA2C83918EF5B9082714A27EB551ECB6AE141B6DACD53CCB4716EE0C5E|0|2|9999696
37719F75798B4240D244A55384F37D586714E8A1A9403134BA37FE9B9FF9EBB3|0|2|898861
A3EB7AE71C5A615A5159CF5DB598BC10E1FDA9E1014A4940B9D88DE626E9DF65|0|2|998967
67B47F0EFE1005256920524AF828FE49AA660B35DF01250D81A98985BC27F79C|1|2|42998267
3741387DA93064D9EC3A6516D94B577180EDEAB25C2C1E10682F0287BB2D646E|1|2|8999241
42AF84905B574299FCA732E04586A9F56CD2C50D0F27F8352E8B639A710E87C9|0|2|999214
D6B7F5387576CA1C687B8198BF510D9A197F1523893B81938E63A4162E9A2043|1|2|8999542
F442A85BBF2FE157596511DB196D81EE0FD5134CBB08B0875C514D3B956372DB|0|2|897604
B969F2D11B02D6FD007F2E31C1620EDEB6E45CB70CA1A579DAC86856A5BB0A50|1|2|41998113
9AEE03AFCB891BEBB70990205A911E8F98A689D16419553AD43D6A9425A46037|1|0|7999087
C3A9F5C40A006D2B7C47822BFA30084235D808CBF5ECE4F8A9EA4A7A340C293C|1|2|8998532
81632CA2D2D4E708BE473C5FC54381B5F95E3CDD818C45611E49A4789B90FB4C|1|2|41895493
B84CD6A0B34609E493FB1D2115920BFDE9A6FC83C39452FC65F183536DBF5C99|1|2|6998935
D5F7734C5DEC57040C3676EF0A5BEAC6868947B92942FE2E5E028CC1BF96AC80|1|2|7858342
B1C20FDC768005C44A663AD08F4CABED8EA50A6B7477EAFDF3DA66522DD1BA33|1|2|40755303
59751EDC871B605A236461DA41D714AC9656A0BDB0DFF294777E475837D45F66|1|2|5844776
00C6F5FFECB9BBF7E059EA5A9F369EF658679690FEFED6E9236740A0CF760AA8|1|2|6704183
1DA6389FF6475448E927C3FD64FFE131C3495302FC699315EC1E08A0D48626CF|1|0|39752637
AB2253AD0474E006C0DAF4D528D5DCE8220E19F9FF8ECDDD67640F636540FC2C|1|2|4842110
158BF6C859E74DFB8B23B583944FB055FFBBFDBD5027F4DF4F98168232909D32|0|0|999695
3A10614767241A47AB5CC55508EA39D6DA9BECDD892CFF230C3E5E81717FC9A4|0|0|999695
86690C0FF8E4FD97505C50CA1503B52730A58314AF72D98953D2D59A3CFAB8ED|0|0|999695
C893D595145BB7B5E45DFDD1B0C5006B510F0F2519117E918ABD64208B6896D5|0|0|999593
B4EDE327C2B5E61E5A0230396DA9BB7320713E4469B9D0DCB0B106C908064673|1|0|5584708
4FECFA59C2003BBBE168443C69AD8950150F65181C93E2B411C582D4FC937133|1|2|3891958
83EAD444700D6F666831E6C03500FC5DBF95E994FA88CD5BC89B0076E730CF18|1|2|7048935
B3A6D18CC6D159255799C45B86651D420D1DD3DD44033E1F06DD73875367D401|1|2|7048935
8AB37F6EB1E9A46246066A038C050054E9325181DD1A02B412D77D3C14073BA6|1|2|38802485
D4AA9742062003D17A4A2D81C6543C7EDBF9B189D37EEAC88238F0F6E968CEEC|0|2|49543

@cdecker
Copy link
Member

cdecker commented Mar 12, 2018

My bad, it was in there, I just miscopied the txid: the following lines are what I was looking for

158BF6C859E74DFB8B23B583944FB055FFBBFDBD5027F4DF4F98168232909D32|0|0|999695
{ "txid" : "329d90328216984fdff42750bdfdbbff55b04f9483b5238bfb4de759c8f68b15", "output" : 0, "value" : 999695, "status" : "confirmed" },

(hashes in the db are reversed since they are kept in the hash-order and not little-endian).

Those values seem to match the actual output values: 0.00999695 BTC. The first transaction above is decoded into:

{
  "txid": "ecce68e9f6f03882c8ea7ed389b1f9db7e3c54c6812d4a7ad10320064297aad4",
  "hash": "fda2a22b01735456284bb4a3094ab970dde95d2c6aa70fc5588ab436bb21cbf8",
  "version": 2,
  "size": 234,
  "vsize": 153,
  "locktime": 0,
  "vin": [
    {
      "txid": "329d90328216984fdff42750bdfdbbff55b04f9483b5238bfb4de759c8f68b15",
      "vout": 0,
      "scriptSig": {
        "asm": "",
        "hex": ""
      },
      "txinwitness": [
        "3044022044a2a9a63a34d73bec8ec3873b1f31b8177b07a9a71c630df04ec679c63b1d2b02207ce83dcb73ae6dbcab8d9a4f0893f4439e5447c523b1a3745871e613cabeb21501",
        "02d263d904d10206f426099b6f4bd839b221ca2743f5e40b56871726aa7f150379"
      ],
      "sequence": 4294967295
    }
  ],
  "vout": [
    {
      "value": 0.00049543,
      "n": 0,
      "scriptPubKey": {
        "asm": "0 5231c938e2213be703e3b3926e4fda4c1b68ce1e",
        "hex": "00145231c938e2213be703e3b3926e4fda4c1b68ce1e",
        "reqSigs": 1,
        "type": "witness_v0_keyhash",
        "addresses": [
          "tb1q2gcujw8zyya7wqlrkwfxun76fsdk3ns7ver97a"
        ]
      }
    },
    {
      "value": 0.00950000,
      "n": 1,
      "scriptPubKey": {
        "asm": "0 87d6c3b1e3b2bc251ee0c79d09ae8e85c1a7e05ec72314e281dc21877928ee38",
        "hex": "002087d6c3b1e3b2bc251ee0c79d09ae8e85c1a7e05ec72314e281dc21877928ee38",
        "reqSigs": 1,
        "type": "witness_v0_scripthash",
        "addresses": [
          "tb1qsltv8v0rk27z28hqc7wsnt5wshq60cz7cu33fc5pmsscw7fgacuqwynsge"
        ]
      }
    }
  ]
}

Which results in a fee of 0.00999695 - (0.00950000 + 0.00049543) = 1.52e-6, not negative, but rather on the small side. Probably just an artifact of estimatesmartfee not being all that smart? My guess is that if repeated again this will not happen?

@hkjn
Copy link

hkjn commented Mar 12, 2018

@cdecker: Let me know if I'm missing something, but regardless of potential wacky responses from estimatesmartfee, if c-lightning produces a tx with fee less than bitcoind's configured minrelaytxfee, the tx will not make it to mempool / be relayed to other nodes for mining.

So unless the user notices and diagnoses the issue, lowers minrelaytxfee and finally retransmits the tx, it seems that the channel funding tx can't be mined. It seems to me that this situation either should be avoided by c-lightning (e.g. using getnetworkinfo output to create a tx with sufficient fee), or if it occurs handled somehow (like taking the channel from CHANNELD_AWAITING_LOCKIN to some failure state).

@ZmnSCPxj
Copy link
Contributor

Yes, we should really impose a timeout on CHANNELD_AWAITING_LOCKIN and fail the channel if this persists for too long. Indeed, the spec requires this behavior if we are the fundee, and it should be reasonable for the funder to behave similarly.

@fixone
Copy link
Contributor Author

fixone commented Mar 12, 2018

I think the timeout is a good idea, especially if something like getrawtransaction <txid> yields an error code -5 when run against the bitcoin node used to propagate it. Since, in a generic setup (i.e. only over RPC), I don't think that there's a way for a client to find the minrelayfee (is there?), if the sendrawtransaction ends up in an error -66, lightningd should probably rebuild the transaction with a slightly higher fee. Or alternatively have a param to specify fee when doing fundchannel.

@ZmnSCPxj
Copy link
Contributor

Can you provide logs regarding what we got from estimatesmartfee around the time you attempted funding the channel?

@fixone
Copy link
Contributor Author

fixone commented Mar 13, 2018

I could only find one call to estimatesmartfee, but it is not related to any of those fundings (it's an earlier call and reads bitcoin-cli -testnet estimatesmartfee 2 CONSERVATIVE exited with status 1)

@redstorm1
Copy link

I am also seeing this behavior.
2018-03-13T20:20:38.013Z lightningd(31613): 03933884aaf1d6b108397e5efe5c86bcf2d8ca8d2f700eda99db9214fc2712b134 chan #1: Peer permanent failure in CHANNELD_AWAITING_LOCKIN: Internal error: Funding broadcast exited with 26: error code: -26?error message:?66: min relay fee not met?

@fixone
Copy link
Contributor Author

fixone commented Mar 13, 2018

here's a more complete log from lightningd from around the time of the failed funding

2018-03-09T07:51:39.359Z lightningd(2550): lightning_openingd-03bf2b602bc3d9dabc6d9172808a0bbe970120ff89be2343ac251980ca8602ffe6 chan #92: pid 839, msgfd 46
2018-03-09T07:51:39.376Z lightningd(2550): lightning_openingd-03bf2b602bc3d9dabc6d9172808a0bbe970120ff89be2343ac251980ca8602ffe6 chan #92: First per_commit_point = 02424a39e61c055f6064efe06
b597b70baf5516857d1607a2886bddba4f5670fb0
2018-03-09T07:51:39.376Z lightningd(2550): lightning_openingd-03bf2b602bc3d9dabc6d9172808a0bbe970120ff89be2343ac251980ca8602ffe6 chan #92: peer_out WIRE_OPEN_CHANNEL
2018-03-09T07:51:39.414Z lightning_gossipd(2558): Failed connected out for 0373337a78afcca9da2831bbf736ea43ddf0887687854e0cbd7540399fb08774cd, will try again
2018-03-09T07:51:39.659Z lightning_gossipd(2558): Connected out for 03477bf5688002984721c1471f49d60197d15e73a13a48fff2de1d542eab35ce39
2018-03-09T07:51:39.696Z lightning_gossipd(2558): Failed connected out for 03477bf5688002984721c1471f49d60197d15e73a13a48fff2de1d542eab35ce39, will try again
2018-03-09T07:51:39.710Z lightning_gossipd(2558): Failed connected out for 0352da80320273889b27f165c36ff6b54de0c9befad5fb2a79fcd3b27d3f1c449e, will try again
2018-03-09T07:51:39.869Z lightningd(2550): lightning_openingd-03bf2b602bc3d9dabc6d9172808a0bbe970120ff89be2343ac251980ca8602ffe6 chan #92: peer_in WIRE_ACCEPT_CHANNEL
2018-03-09T07:51:39.888Z lightningd(2550): lightning_openingd-03bf2b602bc3d9dabc6d9172808a0bbe970120ff89be2343ac251980ca8602ffe6 chan #92: signature 304502210098e56a7ab0b0f660f153971c7de95c
32616a68157d9bb4cb7eae378a54be413f02205496ec845c68acb1657043eab9d6b69fedb53b81f854dff1bc47d4a8ae9e9eb3 on tx 0200000001d4aa9742062003d17a4a2d81c6543c7edbf9b189d37eeac88238f0f6e968ceec010000
00006f594780013b7e0e0000000000160014bbbb4dd28ce2c0957369df4a9a6328458a2ba9e8e1b93120 using key 02c5549c92f4a616a6ea33b149cf6a9876d82134990f4eae764fea0641b52a6da9
2018-03-09T07:51:39.889Z lightningd(2550): lightning_openingd-03bf2b602bc3d9dabc6d9172808a0bbe970120ff89be2343ac251980ca8602ffe6 chan #92: peer_out WIRE_FUNDING_CREATED
2018-03-09T07:51:40.056Z lightningd(2550): lightning_openingd-03bf2b602bc3d9dabc6d9172808a0bbe970120ff89be2343ac251980ca8602ffe6 chan #92: peer_in WIRE_FUNDING_SIGNED
2018-03-09T07:51:40.058Z lightningd(2550): lightning_openingd-03bf2b602bc3d9dabc6d9172808a0bbe970120ff89be2343ac251980ca8602ffe6 chan #92: REPLY WIRE_OPENING_FUNDER_REPLY with 2 fds
2018-03-09T07:51:40.058Z lightningd(2550): 0319c6e91ca1247435d1f19fbacfa629115903d76d6d56733fb0fd480a01d240a9
2018-03-09T07:51:40.058Z lightningd(2550): 03bf2b602bc3d9dabc6d9172808a0bbe970120ff89be2343ac251980ca8602ffe6 chan #92: Funding tx has 1 inputs, 2 outputs:
2018-03-09T07:51:40.058Z lightningd(2550): 03bf2b602bc3d9dabc6d9172808a0bbe970120ff89be2343ac251980ca8602ffe6 chan #92: 0: 999695 satoshi (SEGWIT) 329d90328216984fdff42750bdfdbbff55b04f9483
b5238bfb4de759c8f68b15?
2018-03-09T07:51:40.059Z lightningd(2550): 03bf2b602bc3d9dabc6d9172808a0bbe970120ff89be2343ac251980ca8602ffe6 chan #92: Getting HSM to sign funding tx
2018-03-09T07:51:40.060Z lightningd(2550): Client: Received message 3 from client
2018-03-09T07:51:40.060Z lightningd(2550): Client: Received message 6 from client
(other 7-800 lines of Received message X from client, most of them with X=1)
2018-03-09T07:51:40.094Z lightningd(2550): Client: Received message 1 from client
2018-03-09T07:51:40.094Z lightningd(2550): Client: Received message 1 from client
2018-03-09T07:51:40.094Z lightningd(2550): Client: Received message 1 from client
2018-03-09T07:51:40.094Z lightningd(2550): Client: Received message 1 from client
2018-03-09T07:51:40.094Z lightningd(2550): Client: Received message 1 from client
2018-03-09T07:51:40.094Z lightningd(2550): Client: Received message 1 from client
2018-03-09T07:51:40.094Z lightningd(2550): Client: Received message 4 from client
2018-03-09T07:51:40.117Z lightningd(2550): Owning output 0 49543 (SEGWIT) txid ecce68e9f6f03882c8ea7ed389b1f9db7e3c54c6812d4a7ad10320064297aad4
2018-03-09T07:51:40.117Z lightningd(2550):       (tx ecce68e9f6f03882c8ea7ed389b1f9db7e3c54c6812d4a7ad10320064297aad4)
2018-03-09T07:51:40.117Z lightningd(2550): sendrawtransaction: 02000000000101158bf6c859e74dfb8b23b583944fb055ffbbfdbd5027f4df4f98168232909d320000000000ffffffff0287c10000000000001600145231c938e2213be703e3b3926e4fda4c1b68ce1ef07e0e000000000022002087d6c3b1e3b2bc251ee0c79d09ae8e85c1a7e05ec72314e281dc21877928ee3802473044022044a2a9a63a34d73bec8ec3873b1f31b8177b07a9a71c630df04ec679c63b1d2b02207ce83dcb73ae6dbcab8d9a4f0893f4439e5447c523b1a3745871e613cabeb215012102d263d904d10206f426099b6f4bd839b221ca2743f5e40b56871726aa7f15037900000000
2018-03-09T07:51:40.118Z lightningd(2550): Client: Received message 9 from client
2018-03-09T07:51:40.131Z lightningd(2550): lightning_channeld-03bf2b602bc3d9dabc6d9172808a0bbe970120ff89be2343ac251980ca8602ffe6 chan #92: pid 841, msgfd 54
2018-03-09T07:51:40.131Z lightningd(2550): 03bf2b602bc3d9dabc6d9172808a0bbe970120ff89be2343ac251980ca8602ffe6 chan #92: Waiting for funding confirmations
2018-03-09T07:51:40.131Z lightningd(2550): 03bf2b602bc3d9dabc6d9172808a0bbe970120ff89be2343ac251980ca8602ffe6 chan #92: Ignoring fee limits!
2018-03-09T07:51:40.136Z lightningd(2550):jcon fd 39: Success
2018-03-09T07:51:40.138Z lightningd(2550): sendrawtx exit 26, gave error code: -26?error message:?66: min relay fee not met?
2018-03-09T07:51:40.138Z lightningd(2550): 03bf2b602bc3d9dabc6d9172808a0bbe970120ff89be2343ac251980ca8602ffe6 chan #92: Peer internal error CHANNELD_AWAITING_LOCKIN: Funding broadcast exited with 26: error code: -26?error message:?66: min relay fee not met?
2018-03-09T07:51:40.138Z lightningd(2550): 03bf2b602bc3d9dabc6d9172808a0bbe970120ff89be2343ac251980ca8602ffe6 chan #92: Peer permanent failure in CHANNELD_AWAITING_LOCKIN: Internal error: Funding broadcast exited with 26: error code: -26?error message:?66: min relay fee not met?
2018-03-09T07:51:40.139Z lightningd(2550): lightning_channeld-03bf2b602bc3d9dabc6d9172808a0bbe970120ff89be2343ac251980ca8602ffe6 chan #92: Status closed, but not exited. Killing
2018-03-09T07:51:40.139Z lightningd(2550):       (tx 652c6b4aef3307a2eddc7a8364e2c725b7440a9a0864fc5b837c112b0123804b)
2018-03-09T07:51:40.140Z lightningd(2550): sendrawtransaction: 02000000000101d4aa9742062003d17a4a2d81c6543c7edbf9b189d37eeac88238f0f6e968ceec01000000006f594780013b7e0e000000000022002074cf1d13ccdb44df0edd2cec13a217ab5a376d80c9874c867ca5fbf82c8184d20400473044022058a94ff73eb444b36c818ae7949bffc65e6bcaee0b10cbfee74405e3292f745d0220086ffd0b11975dd7baf407f056844eead3efa5b3539f6fd9e5c5d0700ec288370148304502210098f4eac42365e95aea3724efa6b503fea798a2361f6525b216c23a459938f48d02204477823e4875f082a3962815c4ebb7f95bb551d50e1019611160f40413b3560201475221021e7e169bac2fbd6d078f4543303451079e3402fde5bec734c7aaf8a72513c4082102c5549c92f4a616a6ea33b149cf6a9876d82134990f4eae764fea0641b52a6da952aee1b93120
2018-03-09T07:51:40.141Z lightning_gossipd(2558): Forgetting remote peer 03bf2b602bc3d9dabc6d9172808a0bbe970120ff89be2343ac251980ca8602ffe6
2018-03-09T07:51:40.146Z lightningd(2550): sendrawtx exit 25, gave error code: -25?error message:?Missing inputs?
2018-03-09T07:51:41.777Z lightning_gossipd(2558): Failed connected out for 02147fdc19c7782271ee3418a9a5946c1e413801e43efdd48b80b48af0cfd76404, will try again
2018-03-09T07:51:43.994Z lightning_gossipd(2558): Failed connected out for 024b917abd54e1d70e719fd6aba4b9d9a7384ebe3c3014fc2ff9c39c0001e61062, will try again
2018-03-09T07:51:44.429Z lightning_gossipd(2558): Failed connected out for 0373337a78afcca9da2831bbf736ea43ddf0887687854e0cbd7540399fb08774cd, will try again
2018-03-09T07:51:44.733Z lightning_gossipd(2558): Connected out for 03477bf5688002984721c1471f49d60197d15e73a13a48fff2de1d542eab35ce39
2018-03-09T07:51:44.763Z lightning_gossipd(2558): Failed connected out for 0352da80320273889b27f165c36ff6b54de0c9befad5fb2a79fcd3b27d3f1c449e, will try again
2018-03-09T07:51:44.771Z lightning_gossipd(2558): Failed to connect after 10 attempts, giving up after 46 seconds

@roconnor-blockstream
Copy link

I'm also getting the same issue

2018-03-14T23:25:32.166Z lightningd(1245): sendrawtransaction: 02000000000101eaed6bb33914713b3d2b4cfefbef15eb9f4efbf4b1700bad670ed53d82dd0ad50100000000ffffffff02404b4c0000000000220020d1e84914ae163da42cf7aa5264ed1b1c10e287f6de3a827e5124eebdffd20a2e38495d0500000000160014b2995377b94a54d0d92f72c00ab7e4a7b3cf393502483045022100c613d099b2816426eb4fa63fff6f5411716b2ee4128d3471c11f05352adac6bb02206c43c5491c9ed96c7c2bfaf91c434bae3aa6b6bfe66cf676007b2a5a5ee84e2701210376045cd73d622aa4cdab103797d8cf0cbdbb2dc667b32bb936a80e9cab6f571000000000
2018-03-14T23:25:32.171Z lightningd(1245): Client: Received message 9 from client
2018-03-14T23:25:32.173Z lightningd(1245): lightning_channeld-02f316bf6bb00b206fe9bf9cf25ace31eb0f79c574e35f511a1ce5f7d5d5eeb76a chan #5: pid 8735, msgfd 23
2018-03-14T23:25:32.174Z lightningd(1245): 02f316bf6bb00b206fe9bf9cf25ace31eb0f79c574e35f511a1ce5f7d5d5eeb76a chan #5: Waiting for funding confirmations
2018-03-14T23:25:32.174Z lightningd(1245): 02f316bf6bb00b206fe9bf9cf25ace31eb0f79c574e35f511a1ce5f7d5d5eeb76a chan #5: Ignoring fee limits!
2018-03-14T23:25:32.174Z lightningd(1245):jcon fd 15: Success
{ "tx" : "02000000000101eaed6bb33914713b3d2b4cfefbef15eb9f4efbf4b1700bad670ed53d82dd0ad50100000000ffffffff02404b4c0000000000220020d1e84914ae163da42cf7aa5264ed1b1c10e287f6de3a827e5124eebdffd20a2e38495d0500000000160014b2995377b94a54d0d92f72c00ab7e4a7b3cf393502483045022100c613d099b2816426eb4fa63fff6f5411716b2ee4128d3471c11f05352adac6bb02206c43c5491c9ed96c7c2bfaf91c434bae3aa6b6bfe66cf676007b2a5a5ee84e2701210376045cd73d622aa4cdab103797d8cf0cbdbb2dc667b32bb936a80e9cab6f571000000000", "txid" : "196f2f6ee6cdc1363c210afca807f3d98f26471deacbf6b0f4d04ba5097ac361" }
2018-03-14T23:25:32.183Z lightningd(1245): sendrawtx exit 26, gave error code: -26?error message:?66: min relay fee not met?
2018-03-14T23:25:32.183Z lightningd(1245): 02f316bf6bb00b206fe9bf9cf25ace31eb0f79c574e35f511a1ce5f7d5d5eeb76a chan #5: Peer internal error CHANNELD_AWAITING_LOCKIN: Funding broadcast exited with 26: error code: -26?error message:?66: min relay fee not met?
2018-03-14T23:25:32.183Z lightningd(1245): 02f316bf6bb00b206fe9bf9cf25ace31eb0f79c574e35f511a1ce5f7d5d5eeb76a chan #5: Peer permanent failure in CHANNELD_AWAITING_LOCKIN: Internal error: Funding broadcast exited with 26: error code: -26?error message:?66: min relay fee not met?
2018-03-14T23:25:32.183Z lightningd(1245): lightning_channeld-02f316bf6bb00b206fe9bf9cf25ace31eb0f79c574e35f511a1ce5f7d5d5eeb76a chan #5: Status closed, but not exited. Killing
2018-03-14T23:25:32.183Z lightningd(1245):       (tx 2031a1a4bf10e46b6947d8089dc1632811d947d19a7146734bd2bb125ae094a7)
$ bitcoin-cli --testnet sendrawtransaction 02000000000101eaed6bb33914713b3d2b4cfefbef15eb9f4efbf4b1700bad670ed53d82dd0ad50100000000ffffffff02404b4c0000000000220020d1e84914ae163da42cf7aa5264ed1b1c10e287f6de3a827e5124eebdffd20a2e38495d0500000000160014b2995377b94a54d0d92f72c00ab7e4a7b3cf393502483045022100c613d099b2816426eb4fa63fff6f5411716b2ee4128d3471c11f05352adac6bb02206c43c5491c9ed96c7c2bfaf91c434bae3aa6b6bfe66cf676007b2a5a5ee84e2701210376045cd73d622aa4cdab103797d8cf0cbdbb2dc667b32bb936a80e9cab6f571000000000
error code: -26
error message:
66: min relay fee not met

@bitonic-cjp
Copy link
Contributor

bitonic-cjp commented Mar 15, 2018

Same here. Interestingly, I also got exactly the same fee in the funding tx: 152 satoshi. Coincidence? I don't think so.

For reference, my funding tx (on testnet):
02000000000101a8ae722ebfa940a5206304eddb9d2d2a7c4f6202e9a2153927ae9193633bc1640100000000ffffffff02404b4c0000000000220020c0739069806578b033bc9c9208559865edd0e47577898b7f2167527132a771dd7c657804000000001600144277c9832c44396b1930c37e112a5afeeb742ce90247304402201c58d6fd5ec738a050020ed1f306a93d6497948daae76ee4ee6c0bd65c39a95c022016d2a3c03e77fe48801ac21e6864b859b211b421a3836c9c0a7ac0c6b34c2e820121026c4728fa1c8ca321689b869ba67d8a157343f0a9b774c508255ea29f3f51336e00000000

This was between two of my own lightningd nodes (both v0.5.2-2016-11-21-2240-gb2ce619b).

Edit: shouldn't the funding node be able to get out of this state by double-spending the funding tx? This could be the behavior if 'close' is called in this state. Behavior has to conform to the protocol though.

@roconnor-blockstream
Copy link

Below is my latest attempt along with results from the estimatefee values on testnet taken immediately afterwards.

2018-03-15T17:42:30.041Z lightningd(1245): Connected json input
2018-03-15T17:42:30.049Z lightning_gossipd(1253): req: type WIRE_GOSSIPCTL_RELEASE_PEER len 35
2018-03-15T17:42:30.049Z lightning_gossipd(1253): REPLY WIRE_GOSSIPCTL_RELEASE_PEER_REPLY with 2 fds
2018-03-15T17:42:30.052Z lightningd(1245): lightning_openingd-0285ce7e864a43b55db37df72a11e0b3d5f25d929c859323de6361bfe422f61b06 chan #6: pid 13212, msgfd 18
2018-03-15T17:42:30.075Z lightningd(1245): lightning_openingd-0285ce7e864a43b55db37df72a11e0b3d5f25d929c859323de6361bfe422f61b06 chan #6: First per_commit_point = 03560e0ee568f71add4f415cd862219271067bfbc9463c195d11f2f090df793fa7
2018-03-15T17:42:30.075Z lightningd(1245): lightning_openingd-0285ce7e864a43b55db37df72a11e0b3d5f25d929c859323de6361bfe422f61b06 chan #6: peer_out WIRE_OPEN_CHANNEL
2018-03-15T17:42:30.852Z lightningd(1245): lightning_openingd-0285ce7e864a43b55db37df72a11e0b3d5f25d929c859323de6361bfe422f61b06 chan #6: peer_in WIRE_ACCEPT_CHANNEL
2018-03-15T17:42:30.865Z lightningd(1245): lightning_openingd-0285ce7e864a43b55db37df72a11e0b3d5f25d929c859323de6361bfe422f61b06 chan #6: signature 304402203188cc0dce0906a1383b82fcec94e9ecd3b8d93f35be61a0d3a275bdc787c7d602203e36a0deb2336d2c0e6dab9d48892c12a34d3fcbdaa84ac79f4b47bbb569a368 on tx 0200000001f07f6e349696a9cfc26a9abf2611df833729f9ab5d3777638d04ce619d74367a0000000000ac929580018b4a4c0000000000160014a815b485f840322c428fdaf0e496f7a9e9711b42ae292d20 using key 0360ac7b3a3e7055af9c3c4e08de703540c0cb8372063fdc3007ccfddf876ed27f
2018-03-15T17:42:30.865Z lightningd(1245): lightning_openingd-0285ce7e864a43b55db37df72a11e0b3d5f25d929c859323de6361bfe422f61b06 chan #6: peer_out WIRE_FUNDING_CREATED
2018-03-15T17:42:31.669Z lightningd(1245): lightning_openingd-0285ce7e864a43b55db37df72a11e0b3d5f25d929c859323de6361bfe422f61b06 chan #6: peer_in WIRE_FUNDING_SIGNED
2018-03-15T17:42:31.670Z lightningd(1245): lightning_openingd-0285ce7e864a43b55db37df72a11e0b3d5f25d929c859323de6361bfe422f61b06 chan #6: REPLY WIRE_OPENING_FUNDER_REPLY with 2 fds
2018-03-15T17:42:31.670Z lightningd(1245): 02861694814c4dce2dc3c2b22935578382d994092b24c1731fbd13e2a7d2e53e54
2018-03-15T17:42:31.670Z lightningd(1245): 0285ce7e864a43b55db37df72a11e0b3d5f25d929c859323de6361bfe422f61b06 chan #6: Funding tx has 1 inputs, 2 outputs:
2018-03-15T17:42:31.670Z lightningd(1245): 0285ce7e864a43b55db37df72a11e0b3d5f25d929c859323de6361bfe422f61b06 chan #6: 0: 94999824 satoshi (SEGWIT) d50add823dd50e67ad0b70b1f4fb4e9feb15effbfe4c2b3d3b711439b36bedea?
2018-03-15T17:42:31.671Z lightningd(1245): 0285ce7e864a43b55db37df72a11e0b3d5f25d929c859323de6361bfe422f61b06 chan #6: Getting HSM to sign funding tx
2018-03-15T17:42:31.671Z lightningd(1245): Client: Received message 1 from client
2018-03-15T17:42:31.671Z lightningd(1245): Client: Received message 4 from client
2018-03-15T17:42:31.673Z lightningd(1245): Owning output 1 89999672 (SEGWIT) txid 7a36749d61ce048d6377375dabf9293783df1126bf9a6ac2cfa99696346e7ff0
2018-03-15T17:42:31.673Z lightningd(1245):       (tx 7a36749d61ce048d6377375dabf9293783df1126bf9a6ac2cfa99696346e7ff0)
2018-03-15T17:42:31.673Z lightningd(1245): sendrawtransaction: 02000000000101eaed6bb33914713b3d2b4cfefbef15eb9f4efbf4b1700bad670ed53d82dd0ad50100000000ffffffff02404b4c00000000002200205c9f87d3391aaf3f60c25750d34719f49d17f2e0fddd66e5033eb31101bd795038495d0500000000160014f6873cc81aca32acca34f60d4c5cfea8b3935eb202473044022043e097a95518a6ff46141e9cf1fe3adee9415256fc013fbeb78eec4f60b1714502203abf88a4283413aaaab1327268e482705506394706b2e65590d0006e8355e73d01210376045cd73d622aa4cdab103797d8cf0cbdbb2dc667b32bb936a80e9cab6f571000000000
2018-03-15T17:42:31.678Z lightningd(1245): Client: Received message 9 from client
2018-03-15T17:42:31.680Z lightningd(1245): lightning_channeld-0285ce7e864a43b55db37df72a11e0b3d5f25d929c859323de6361bfe422f61b06 chan #6: pid 13214, msgfd 23
2018-03-15T17:42:31.680Z lightningd(1245): 0285ce7e864a43b55db37df72a11e0b3d5f25d929c859323de6361bfe422f61b06 chan #6: Waiting for funding confirmations
2018-03-15T17:42:31.680Z lightningd(1245): 0285ce7e864a43b55db37df72a11e0b3d5f25d929c859323de6361bfe422f61b06 chan #6: Ignoring fee limits!
2018-03-15T17:42:31.681Z lightningd(1245):jcon fd 15: Success
{ "tx" : "02000000000101eaed6bb33914713b3d2b4cfefbef15eb9f4efbf4b1700bad670ed53d82dd0ad50100000000ffffffff02404b4c00000000002200205c9f87d3391aaf3f60c25750d34719f49d17f2e0fddd66e5033eb31101bd795038495d0500000000160014f6873cc81aca32acca34f60d4c5cfea8b3935eb202473044022043e097a95518a6ff46141e9cf1fe3adee9415256fc013fbeb78eec4f60b1714502203abf88a4283413aaaab1327268e482705506394706b2e65590d0006e8355e73d01210376045cd73d622aa4cdab103797d8cf0cbdbb2dc667b32bb936a80e9cab6f571000000000", "txid" : "7a36749d61ce048d6377375dabf9293783df1126bf9a6ac2cfa99696346e7ff0" }
2018-03-15T17:42:31.693Z lightningd(1245): sendrawtx exit 26, gave error code: -26?error message:?66: min relay fee not met?
2018-03-15T17:42:31.693Z lightningd(1245): 0285ce7e864a43b55db37df72a11e0b3d5f25d929c859323de6361bfe422f61b06 chan #6: Peer internal error CHANNELD_AWAITING_LOCKIN: Funding broadcast exited with 26: error code: -26?error message:?66: min relay fee not met?
2018-03-15T17:42:31.693Z lightningd(1245): 0285ce7e864a43b55db37df72a11e0b3d5f25d929c859323de6361bfe422f61b06 chan #6: Peer permanent failure in CHANNELD_AWAITING_LOCKIN: Internal error: Funding broadcast exited with 26: error code: -26?error message:?66: min relay fee not met?
2018-03-15T17:42:31.693Z lightningd(1245): lightning_channeld-0285ce7e864a43b55db37df72a11e0b3d5f25d929c859323de6361bfe422f61b06 chan #6: Status closed, but not exited. Killing
2018-03-15T17:42:31.693Z lightningd(1245):       (tx 90a0c3557a458c5a4661a22e1efcf608a9d919c0ca6834767909798f023a4f13)
2018-03-15T17:42:31.694Z lightningd(1245): sendrawtransaction: 02000000000101f07f6e349696a9cfc26a9abf2611df833729f9ab5d3777638d04ce619d74367a0000000000ac929580018b4a4c000000000022002041e55351a4f625c2539d350ca49391985d44c210ceeb27d58257ad9981ab84870400483045022100d1eabb414ac9346da8f34b7538cc6de5898edb1185e671eaf3c5c7af358737860220353863ee0893f3ea52f9aea011cf1280457872b87e9b6bba7e0303922f9c7a7601483045022100d2f4dd184f97b80c29e9c5493f14805c96e208ed7a0c64dd48ac9f59542397ac02200d2d5446d5b03aa45e750c8a74298af5616f57b673b776cef8b88d18bd8865670147522102d0d8a50956a4020af6227dad664f1cd54b63d3e4797ed508ab40afa0e8c8c716210360ac7b3a3e7055af9c3c4e08de703540c0cb8372063fdc3007ccfddf876ed27f52aeae292d20
2018-03-15T17:42:31.701Z lightning_gossipd(1253): Forgetting remote peer 0285ce7e864a43b55db37df72a11e0b3d5f25d929c859323de6361bfe422f61b06
$ bitcoin-cli --testnet estimatesmartfee 2
{
  "feerate": 0.00001005,
  "blocks": 2
}

$ bitcoin-cli --testnet estimatesmartfee 6
{
  "feerate": 0.00001000,
  "blocks": 6
}

$ bitcoin-cli --testnet estimatesmartfee 10
{
  "feerate": 0.00001000,
  "blocks": 10
}

$ bitcoin-cli --testnet estimatesmartfee 100
{
  "feerate": 0.00001000,
  "blocks": 100
}

$ bitcoin-cli --testnet estimatesmartfee 1008
{
  "feerate": 0.00001000,
  "blocks": 883
}

$ bitcoin-cli --testnet sendrawtransaction 02000000000101eaed6bb33914713b3d2b4cfefbef15eb9f4efbf4b1700bad670ed53d82dd0ad50100000000ffffffff02404b4c00000000002200205c9f87d3391aaf3f60c25750d34719f49d17f2e0fddd66e5033eb31101bd795038495d0500000000160014f6873cc81aca32acca34f60d4c5cfea8b3935eb202473044022043e097a95518a6ff46141e9cf1fe3adee9415256fc013fbeb78eec4f60b1714502203abf88a4283413aaaab1327268e482705506394706b2e65590d0006e8355e73d01210376045cd73d622aa4cdab103797d8cf0cbdbb2dc667b32bb936a80e9cab6f571000000000 
error code: -26
error message:
66: min relay fee not met

@fixone
Copy link
Contributor Author

fixone commented Mar 19, 2018

even with a more recent version v0.5.2-2016-11-21-2350-g234d67d, the problem remains, I can't seem to be able to fund any newly opened channels

2018-03-19T05:25:33.576Z lightningd(24491): Client: Received message 1 from client
2018-03-19T05:25:33.576Z lightningd(24491): Client: Received message 1 from client
2018-03-19T05:25:33.576Z lightningd(24491): Client: Received message 1 from client
2018-03-19T05:25:33.576Z lightningd(24491): Client: Received message 1 from client
2018-03-19T05:25:33.576Z lightningd(24491): Client: Received message 1 from client
2018-03-19T05:25:33.576Z lightningd(24491): Client: Received message 4 from client
2018-03-19T05:25:33.617Z lightningd(24491): Owning output 1 7048935 (SEGWIT) txid 286d9d48683e84aa83fdd54e2383c17b239807c85c07b0ddcdca30b1b00d84e2
2018-03-19T05:25:33.617Z lightningd(24491): 	 (tx 286d9d48683e84aa83fdd54e2383c17b239807c85c07b0ddcdca30b1b00d84e2)
2018-03-19T05:25:33.617Z lightningd(24491): sendrawtransaction: 020000000001019aee03afcb891bebb70990205a911e8f98a689d16419553ad43d6a9425a460370100000000ffffffff02f07e0e0000000000220020a651f138b50caa5fb904a44dcd3a57eb6073b7cb739ed5c92cf1c66ad6bf490be78e6b00000000001600144b0f6e778e355d0805232db9cef1fc733976f5ab024830450221008e870ba65bc2d5f1d960651eaa773b6318c9288bdd8f29857b7a3d77083a403e0220695fdf78053c12d685937dc96bbbca6e7a0fefea8951ce156c3818d21d8829570121032339d316d2aef484448e0ead35b49971d52df0cad950c281272ef4abb21139d200000000
2018-03-19T05:25:33.625Z lightningd(24491): Client: Received message 9 from client
2018-03-19T05:25:33.645Z lightningd(24491): lightning_channeld-022c315d7588cf1714159915baae386dc87462b669a7036df33850e9c0a3265893 chan #85: pid 11461, msgfd 28
2018-03-19T05:25:33.645Z lightningd(24491): 022c315d7588cf1714159915baae386dc87462b669a7036df33850e9c0a3265893 chan #85: Waiting for funding confirmations
2018-03-19T05:25:33.645Z lightningd(24491): 022c315d7588cf1714159915baae386dc87462b669a7036df33850e9c0a3265893 chan #85: Ignoring fee limits!
2018-03-19T05:25:33.645Z lightningd(24491):jcon fd 16: Success
2018-03-19T05:25:33.653Z lightningd(24491): sendrawtx exit 26, gave error code: -26?error message:?66: min relay fee not met?
2018-03-19T05:25:33.653Z lightningd(24491): 022c315d7588cf1714159915baae386dc87462b669a7036df33850e9c0a3265893 chan #85: Peer internal error CHANNELD_AWAITING_LOCKIN: Funding broadcast exited with 26: error code: -26?error message:?66: min relay fee not met?
2018-03-19T05:25:33.653Z lightningd(24491): 022c315d7588cf1714159915baae386dc87462b669a7036df33850e9c0a3265893 chan #85: Peer permanent failure in CHANNELD_AWAITING_LOCKIN: Internal error: Funding broadcast exited with 26: error code: -26?error message:?66: min relay fee not met?
2018-03-19T05:25:33.653Z lightningd(24491): lightning_channeld-022c315d7588cf1714159915baae386dc87462b669a7036df33850e9c0a3265893 chan #85: Status closed, but not exited. Killing
2018-03-19T05:25:33.653Z lightningd(24491): 	 (tx 3dab74877c7a2751bab5aa8bdd0331e8d387d6da8022db2116f1736d468a8feb)
2018-03-19T05:25:33.657Z lightningd(24491): sendrawtransaction: 02000000000101e2840db0b130cacdddb0075cc80798237bc183234ed5fd83aa843e68489d6d280000000000c51e8680013b7e0e000000000022002046e49e01d157bdcc6dd8df36c6c044c44912ab8d04314c0816cac8f70d49da0c0400483045022100b8e9ac62017f84b799e4b4e1bf5502043bee029d80df9cd344a6e00e02cbfd7b02204116b22067e97c589769fee7dd26485248bdb424ba427fce9ad93dce49e9e15a0147304402202d7e9659e02e3aed63506fb176dd2077ae189e29dfa1b656514a7a47db3abed402201ed4c924c068eab29ea9598162dbce8cc9a4e06995c8a8089d38d61b54010cd10147522102481d01a3007dcd44dc13482cdfa60e9bf89250fd41d0bdb3bab1e3e9315b3b0021034500823593906e2d9f855d00de2c368d8f8fa557f6404e1b33a1b8f819b19d1c52aecaf80420
2018-03-19T05:25:33.661Z lightning_gossipd(24499): Forgetting remote peer 022c315d7588cf1714159915baae386dc87462b669a7036df33850e9c0a3265893
2018-03-19T05:25:33.672Z lightningd(24491): sendrawtx exit 25, gave error code: -25?error message:?Missing inputs?
2018-03-19T05:25:35.374Z lightning_gossipd(24499): peer_in WIRE_PING
2018-03-19T05:25:35.374Z lightning_gossipd(24499): peer_out WIRE_PONG

@ZmnSCPxj
Copy link
Contributor

It has not been fixed yet. The issue is that there is no bitcoind RPC command that lets us query the minimum relay fee. Possibly we need to make it into an option to lightningd, with a default similar or higher than bitcoind default, then when querying estimatesmartfee we use the minimum relay fee if estimatesmartfee gives something lower.

@fixone
Copy link
Contributor Author

fixone commented Mar 19, 2018

Yeah, I believe that you should use estimatesmartfee but also when error 66 is thrown on sendrawtransaction the fee should be increased slightly and then rinse and repeat

@ZmnSCPxj
Copy link
Contributor

This is not so easy! Changing the fee changes the txid of the funding transaction.

Unfortunately the txid of the funding transaction is negotiated beforehand because the first commitment transaction that returns the money back to the funder must get signed before the funding transaction is signed and broadcast.

This means we need to restart the opening negotiation.

In theory what we can do if we are the funder, and, we get this error 66:

  1. Send error message to counterparty, hopefully this will make counterparty forget the channel (since it has no stake in that channel, but note that some older version of c-lightning about a few weeks ago will remember such channels forever anyway).
  2. Reset our view of UTXOs.
  3. Bump our fees up.

(The above is almost similar to what we would do if we implement RBF on channel funding, BTW, but there are tricky issues regarding RBF which make it painful to implement for us now)

But the above is significantly more complex and requires careful planning of the DB. The simple "if dumb estimatesmartfee gives a feerate below our configured minimum relay fee" can be hacked in a few hours. The question is if we should do things properly and use fee-boosting or if the simple hack is good enough.

@roconnor-blockstream
Copy link

roconnor-blockstream commented Mar 19, 2018

bitcoin-cli getmempoolinfo returns the minrelaytxfee. Is that not what is needed? But estimatesmartfee always returns at least this value, so I'm kinda confused as to why 152 satoshi fees are being suggested when a 153 vbyte transaction requires a fee of 153 satoshi. This simply sounds like a rounding error in clightning, presumably in how it is calculating vbytes.

@roconnor-blockstream
Copy link

See the fee calculations round down @

fee = feerate_per_kw * (measure_tx_weight(tx)
+ 1 + 3 + 73 + 0 + tal_len(wscript))
/ 1000;

Just change that to

	fee = (999 + feerate_per_kw * (measure_tx_weight(tx)
			 + 1 + 3 + 73 + 0 + tal_len(wscript)))
		/ 1000;

@rustyrussell
Copy link
Contributor

We can fix our own txs (and should) but the feerate to fee calc is a consensus issue detailed in the spec. This probably means we need to correct the feerate with a floor, so we negotiate so this Never Happens for commitment txs.

And probing for our own minrelayfee is pointless: we need everyone else's. In practice, that's 1000.

@rustyrussell
Copy link
Contributor

If feerate_per_kw is 1000, this is not a rounding problem! It's the old braindead bitcoind code. Fix incoming.

rustyrussell added a commit to rustyrussell/lightning that referenced this issue Mar 20, 2018
Naively, this would be 4000 satoshi per sipa, but it's not since bitcoind's
fee calculation was not rewritten to deal with weight, but instead bolted
on using vbytes.

The resulting calculations made me cry; I dried my tears on the thorns
of BUILD_ASSERT (I know that makes no sense, but bear with me here as I'm
trying not to swear at my bitcoind colleagues right now).

Fixes: ElementsProject#1194
Signed-off-by: Rusty Russell <[email protected]>
rustyrussell added a commit to rustyrussell/lightning that referenced this issue Mar 20, 2018
Naively, this would be 250 satoshi per sipa, but it's not since bitcoind's
fee calculation was not rewritten to deal with weight, but instead bolted
on using vbytes.

The resulting calculations made me cry; I dried my tears on the thorns
of BUILD_ASSERT (I know that makes no sense, but bear with me here as I'm
trying not to swear at my bitcoind colleagues right now).

Fixes: ElementsProject#1194
Signed-off-by: Rusty Russell <[email protected]>
cdecker pushed a commit that referenced this issue Mar 20, 2018
Naively, this would be 250 satoshi per sipa, but it's not since bitcoind's
fee calculation was not rewritten to deal with weight, but instead bolted
on using vbytes.

The resulting calculations made me cry; I dried my tears on the thorns
of BUILD_ASSERT (I know that makes no sense, but bear with me here as I'm
trying not to swear at my bitcoind colleagues right now).

Fixes: #1194
Signed-off-by: Rusty Russell <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants