Test that withdraw correctly signs close outputs (anchor/P2WSH). Regression test for https://github.com/ElementsProject/lightning/issues/8701 The original issue involved spending channel close outputs (with option_anchors CSV=1) alongside regular wallet UTXOs.
(node_factory, bitcoind)
| 2136 | |
| 2137 | @unittest.skipIf(TEST_NETWORK != 'regtest', "Uss p2tr") |
| 2138 | def test_withdraw_close_output_signed(node_factory, bitcoind): |
| 2139 | """ |
| 2140 | Test that withdraw correctly signs close outputs (anchor/P2WSH). |
| 2141 | |
| 2142 | Regression test for https://github.com/ElementsProject/lightning/issues/8701 |
| 2143 | The original issue involved spending channel close outputs (with |
| 2144 | option_anchors CSV=1) alongside regular wallet UTXOs. |
| 2145 | """ |
| 2146 | l1, l2 = node_factory.line_graph(2, fundchannel=True, wait_for_announce=True) |
| 2147 | |
| 2148 | # Close the channel so l1 gets a close output |
| 2149 | l1.rpc.close(l2.info['id']) |
| 2150 | bitcoind.generate_block(1, wait_for_mempool=1) |
| 2151 | |
| 2152 | # Wait for CSV lock (1 block for anchors) and the close output to mature |
| 2153 | bitcoind.generate_block(100) |
| 2154 | sync_blockheight(bitcoind, [l1]) |
| 2155 | |
| 2156 | wait_for(lambda: all(o['status'] == 'confirmed' for o in l1.rpc.listfunds()['outputs'])) |
| 2157 | |
| 2158 | # Withdraw all funds - this spends both regular and close outputs |
| 2159 | waddr = l1.bitcoin.rpc.getnewaddress() |
| 2160 | out = l1.rpc.withdraw(waddr, 'all') |
| 2161 | |
| 2162 | decoded = bitcoind.rpc.decoderawtransaction(out['tx']) |
| 2163 | |
| 2164 | # Every input must have witness data |
| 2165 | for i, vin in enumerate(decoded['vin']): |
| 2166 | assert 'txinwitness' in vin, \ |
| 2167 | f"Input {i} has no witness data - tx is unsigned! (issue #8701)" |
| 2168 | assert len(vin['txinwitness']) > 0, \ |
| 2169 | f"Input {i} has empty witness stack" |
| 2170 | |
| 2171 | assert decoded['txid'] == out['txid'] |
| 2172 | |
| 2173 | |
| 2174 | def test_withdraw_nlocktime(node_factory): |
nothing calls this directly
no test coverage detected