I can not reply your whole questions, however I can provide you some assist.
From the bitcoin standpoint, you’ll be able to at all times spend a transaction output (TXO) if it isn’t spent already by some confirmed transaction.
That mentioned, when you opened a channel however the funding transaction will not be confirmed you’ll be able to spend the TXO that funded the channel, however I do not know the way lightningd would react to this.
You mentioned you’ve gotten closed the channel. In case you funds are nonetheless caught it means each the funding channel and shut channel transactions are unconfirmed within the mempool.
I might attempt to spend the TXO within the shut TX in a child-pays-for-parent vogue. Nonetheless, when making an attempt to breed that state of affairs in regtest I discover troubles with the clightning person interface.
I did the next to simulate your scenario:
- I create a channel with peer
$ l1-cli fundchannel 0397d48baf82cf731fc8967c16e3d9575f10606bdf481738eb9cafeda29d0e3d67 1000000sat
{
"tx": "02000000000101ee026cb7c44f482eb9b1e11f6faf11956ac26f4cdb7e0c1aa9ef94025ec412c30000000000fdffffff0240420f000000000022002075e9a102dbb348646e2f1804cc3cfec9edb6f5551a074f33a615f29cbd45eeaa4c5bd70500000000160014deb1f4e1123694ca3e418cefe496d3c26b0ddde202473044022068b402d53f16204324b28607eca046a4f7121d8f83c62e17de9c9131e307b5cf022077a3aa538469f9e0983cce98c3de4c5427731b398ed395d9614cf7b54d4f5cdd012102f5093f8fd66c909fc72ee556e70cb038ae92b03fd1b56d710cf53b3cc019868e73000000",
"txid": "11b8967c62c584da9bbba5243d61bc95b4da210760bca04adb7c349319edba19",
"channel_id": "9dfe0df4c502c31e92c266bfa28af18d6f6d11a0b0197b838797f8c990625168",
"outnum": 0
}
- I closed the channel
$ l1-cli -k shut id=9dfe0df4c502c31e92c266bfa28af18d6f6d11a0b0197b838797f8c990625168
# Sending closing price supply 139sat, with vary 139sat-183sat
# Obtained closing price supply 139sat, with vary 139sat-1000000sat
{
"tx": "020000000119baed1993347cdb4aa0bc600721dab495bc613d24a5bb9bda84c5627c96b8110000000000ffffffff01b5410f00000000001600141b420a80810dda8fd3621e6ba4ce14ce85b6877e00000000",
"txid": "e6a7d6cc0960f0f7481a3e9a18b9d9cc18ee695dd626a597883be4599c043699",
"kind": "mutual"
}
At this level each the funding (11b896...
) and settlement (e6a7d6cc...
) transactions are within the mempool and unconfirmed.
The scenario is proven within the diagram under
tx:c312c...(confirmed) ---> tx:11b89... (funding tx unconfirmed) ---> tx:e6a7d6cc... (settlement, unconfirmed)
My thought is to spend the settlement output with a better price.
Nonetheless, I’ve issues with lightning-cli
to get this working.
If I attempt to spend the settlement output, which is managed by my pockets:
$ l1-cli -k txprepare outputs="[{"bcrt1qx77wq9fyxvhsncswpl6kgqpnc49m5e5lzmls0g":"all"}]" utxos="["e6a7d6cc0960f0f7481a3e9a18b9d9cc18ee695dd626a597883be4599c043699:0"]" feerate=100
{
"code": -32602,
"message": "Unknown UTXO e6a7d6cc0960f0f7481a3e9a18b9d9cc18ee695dd626a597883be4599c043699:0"
}
So most likely lightnind is saying: “that UTXO will not be within the blockchain, I can not spend it”.
I attempted a work-around, making a PSBT with bitcoin-cli
:
$ bt-cli createpsbt "[{"txid":"e6a7d6cc0960f0f7481a3e9a18b9d9cc18ee695dd626a597883be4599c043699","vout":0}]" "[{"bcrt1qx77wq9fyxvhsncswpl6kgqpnc49m5e5lzmls0g":0.00900000}]"
cHNidP8BAFICAAAAAZk2BJxZ5DuIl6Um1l1p7hjM2bkYmj4aSPfwYAnM1qfmAAAAAAD9////AaC7DQAAAAAAFgAUN7zgFSQzLwniDg/1ZAAzxUu6Zp8AAAAAAAAA
after which signing it with lightning-cli
:
$ l1-cli signpsbt cHNidP8BAFICAAAAAZk2BJxZ5DuIl6Um1l1p7hjM2bkYmj4aSPfwYAnM1qfmAAAAAAD9////AaC7DQAAAAAAFgAUN7zgFSQzLwniDg/1ZAAzxUu6Zp8AAAAAAAAA
{
"code": -1,
"message": "No pockets inputs to signal"
}
Evidently clightning would not prefer to signal transactions inputs that aren’t confirmed.
I might spend the TXO that funded the channel because the funding transaction is unconfirmed.
$ l1-cli -k txprepare outputs="[{"bcrt1qx77wq9fyxvhsncswpl6kgqpnc49m5e5lzmls0g":"all"}]" utxos="["c312c45e0294efa91a0c7edb4c6fc26a9511af6f1fe1b1b92e484fc4b76c02ee:0"]" feerate=100
{
"code": -32602,
"message": "UTXO c312c45e0294efa91a0c7edb4c6fc26a9511af6f1fe1b1b92e484fc4b76c02ee:0 already reserved"
}
So, clightning
sees that despite the fact that that TXO will not be confirmed it’s spent by a channel funding.
Let me attempt forcing once more with bitcoin core PSBT:
$ bt-cli createpsbt "[{"txid":"c312c45e0294efa91a0c7edb4c6fc26a9511af6f1fe1b1b92e484fc4b76c02ee","vout":0}]" "[{"bcrt1qx77wq9fyxvhsncswpl6kgqpnc49m5e5lzmls0g":0.98900000}]"
cHNidP8BAFICAAAAAe4CbLfET0guubHhH2+vEZVqwm9M234MGqnvlAJexBLDAAAAAAD9////ASAY5QUAAAAAFgAUN7zgFSQzLwniDg/1ZAAzxUu6Zp8AAAAAAAAA
after which get a signature from clightning pockets:
$ l1-cli signpsbt cHNidP8BAFICAAAAAe4CbLfET0guubHhH2+vEZVqwm9M234MGqnvlAJexBLDAAAAAAD9////ASAY5QUAAAAAFgAUN7zgFSQzLwniDg/1ZAAzxUu6Zp8AAAAAAAAA
{
"signed_psbt": "cHNidP8BAFICAAAAAe4CbLfET0guubHhH2+vEZVqwm9M234MGqnvlAJexBLDAAAAAAD9////ASAY5QUAAAAAFgAUN7zgFSQzLwniDg/1ZAAzxUu6Zp8AAAAAAAEBHyae5gUAAAAAFgAUrxY3yj79dai67Z9mJ4hHAjQSIzMiAgL1CT+P1myQn8cu5VbnDLA4rpKwP9G1bXEM9Ts8wBmGjkcwRAIgMdOln+3Bzrm5lWqUrBbtEleqYgclYdwSadbs7T8V+18CIFTRsrlwhdZrvrG+UiCGf44+TJrF+Oqj4w+hLFmucBcfASIGAvUJP4/WbJCfxy7lVucMsDiukrA/0bVtcQz1OzzAGYaOCK8WN8oAAAAAACICAoqr3sVLia14vPyrtYQRxA+wniCHWDV34AMh8C5p18haCDe84BUHAAAAAA=="
}
OK, so this time we’ve a signature, now we are able to assemble the transaction
$ bt-cli finalizepsbt "cHNidP8BAFICAAAAAe4CbLfET0guubHhH2+vEZVqwm9M234MGqnvlAJexBLDAAAAAAD9////ASAY5QUAAAAAFgAUN7zgFSQzLwniDg/1ZAAzxUu6Zp8AAAAAAAEBHyae5gUAAAAAFgAUrxY3yj79dai67Z9mJ4hHAjQSIzMiAgL1CT+P1myQn8cu5VbnDLA4rpKwP9G1bXEM9Ts8wBmGjkcwRAIgMdOln+3Bzrm5lWqUrBbtEleqYgclYdwSadbs7T8V+18CIFTRsrlwhdZrvrG+UiCGf44+TJrF+Oqj4w+hLFmucBcfASIGAvUJP4/WbJCfxy7lVucMsDiukrA/0bVtcQz1OzzAGYaOCK8WN8oAAAAAACICAoqr3sVLia14vPyrtYQRxA+wniCHWDV34AMh8C5p18haCDe84BUHAAAAAA=="
{
"hex": "02000000000101ee026cb7c44f482eb9b1e11f6faf11956ac26f4cdb7e0c1aa9ef94025ec412c30000000000fdffffff012018e5050000000016001437bce01524332f09e20e0ff5640033c54bba669f02473044022031d3a59fedc1ceb9b9956a94ac16ed1257aa62072561dc1269d6eced3f15fb5f022054d1b2b97085d66bbeb1be5220867f8e3e4c9ac5f8eaa3e30fa12c59ae70171f012102f5093f8fd66c909fc72ee556e70cb038ae92b03fd1b56d710cf53b3cc019868e00000000",
"full": true
}
and broadcast it
$ bt-cli sendrawtransaction 02000000000101ee026cb7c44f482eb9b1e11f6faf11956ac26f4cdb7e0c1aa9ef94025ec412c30000000000fdffffff012018e5050000000016001437bce01524332f09e20e0ff5640033c54bba669f02473044022031d3a59fedc1ceb9b9956a94ac16ed1257aa62072561dc1269d6eced3f15fb5f022054d1b2b97085d66bbeb1be5220867f8e3e4c9ac5f8eaa3e30fa12c59ae70171f012102f5093f8fd66c909fc72ee556e70cb038ae92b03fd1b56d710cf53b3cc019868e00000000
41304c4e992a0718d29cf7c46adb0f361c319d31b92eeb8d7dbc811aebc2b39f
If the miners embrace the final transaction 41304...
, then the funding 11b896...
and settlement e6a7...
will probably be invalid. However you continue to have your funds.
tx:c312c...(confirmed) -X-> tx:11b89... (funding tx unconfirmed) -X-> tx:e6a7d6cc... (settlement, unconfirmed)
|
+---> tx:41304... (confirmed)
Unintended effects
clightning sees the brand new funds, however it’s nonetheless ready for the earlier transactions to verify:
$ l1-cli listfunds
{
"outputs": [
{
"txid": "11b8967c62c584da9bbba5243d61bc95b4da210760bca04adb7c349319edba19",
"output": 1,
"amount_msat": 97999692000,
"scriptpubkey": "0014deb1f4e1123694ca3e418cefe496d3c26b0ddde2",
"address": "bcrt1qm6clfcgjx62v50jp3nh7f9kncf4smh0z2v5q3d",
"status": "unconfirmed",
"reserved": false
},
{
"txid": "41304c4e992a0718d29cf7c46adb0f361c319d31b92eeb8d7dbc811aebc2b39f",
"output": 0,
"amount_msat": 98900000000,
"scriptpubkey": "001437bce01524332f09e20e0ff5640033c54bba669f",
"address": "bcrt1qx77wq9fyxvhsncswpl6kgqpnc49m5e5lzmls0g",
"status": "confirmed",
"blockheight": 116,
"reserved": false
}
],
"channels": [
{
"peer_id": "0232a73b00b1e4eb6ee1787785640dca55a67bf5e6b338e42efff6a9b21da26c93",
"connected": true,
"state": "CHANNELD_NORMAL",
"channel_id": "a8664ad1bbc4debd16ea2a49b07167f35d3dd9cacac60c0ad6d60fbb76ce78e7",
"short_channel_id": "103x1x1",
"our_amount_msat": 1000000000,
"amount_msat": 1000000000,
"funding_txid": "c312c45e0294efa91a0c7edb4c6fc26a9511af6f1fe1b1b92e484fc4b76c02ee",
"funding_output": 1
}
]
}