(node_factory, bitcoind)
| 159 | @pytest.mark.openchannel('v2') |
| 160 | @unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need') |
| 161 | def test_two_chan_splice_in(node_factory, bitcoind): |
| 162 | l1, l2, l3 = node_factory.line_graph(3, fundamount=1000000, wait_for_announce=True) |
| 163 | |
| 164 | # l2 will splice funds into the channels with l1 and l3 at the same time |
| 165 | |
| 166 | chan_id1 = l2.get_channel_id(l1) |
| 167 | chan_id2 = l2.get_channel_id(l3) |
| 168 | |
| 169 | # add extra sats to pay fee |
| 170 | funds_result = l2.rpc.fundpsbt("211722sat", 0, 0, excess_as_change=True) |
| 171 | |
| 172 | # Intiate splices to both channels |
| 173 | result = l2.rpc.splice_init(chan_id1, 100000, funds_result['psbt']) |
| 174 | result = l2.rpc.splice_init(chan_id2, 100000, result['psbt']) # start with psbt from first channel |
| 175 | |
| 176 | done1 = False |
| 177 | done2 = False |
| 178 | sigs1 = False |
| 179 | sigs2 = False |
| 180 | |
| 181 | while not done1 or not done2: |
| 182 | if not done1: |
| 183 | result = l2.rpc.splice_update(chan_id1, result['psbt']) |
| 184 | done1 = result['commitments_secured'] |
| 185 | sigs1 = result['signatures_secured'] |
| 186 | print("chan 1 " + result['psbt']) |
| 187 | if not done2: |
| 188 | result = l2.rpc.splice_update(chan_id2, result['psbt']) |
| 189 | done2 = result['commitments_secured'] |
| 190 | sigs2 = result['signatures_secured'] |
| 191 | print("chan 2 " + result['psbt']) |
| 192 | |
| 193 | # Due to splice signing order, we may or may not have signatures |
| 194 | # from all peers, but we must have them from one. |
| 195 | print("Sigs1 " + str(sigs1) + ", Sigs2 " + str(sigs2)) |
| 196 | assert(sigs1 or sigs2) |
| 197 | |
| 198 | # Sign the inputs provided by `fundpsbt` |
| 199 | result = l2.rpc.signpsbt(result['psbt']) |
| 200 | result['psbt'] = result['signed_psbt'] |
| 201 | |
| 202 | if sigs2: |
| 203 | # If chan2 gave us sigs, start with chan1 |
| 204 | result = l2.rpc.splice_signed(chan_id1, result['psbt']) |
| 205 | result = l2.rpc.splice_signed(chan_id2, result['psbt']) |
| 206 | else: |
| 207 | # If chan1 gave us sigs, start with chan2 |
| 208 | result = l2.rpc.splice_signed(chan_id2, result['psbt']) |
| 209 | result = l2.rpc.splice_signed(chan_id1, result['psbt']) |
| 210 | |
| 211 | l3.daemon.wait_for_log(r'CHANNELD_NORMAL to CHANNELD_AWAITING_SPLICE') |
| 212 | l2.daemon.wait_for_log(r'CHANNELD_NORMAL to CHANNELD_AWAITING_SPLICE') |
| 213 | l1.daemon.wait_for_log(r'CHANNELD_NORMAL to CHANNELD_AWAITING_SPLICE') |
| 214 | |
| 215 | wait_for(lambda: len(list(bitcoind.rpc.getrawmempool(True).keys())) == 1) |
| 216 | assert result['txid'] in list(bitcoind.rpc.getrawmempool(True).keys()) |
| 217 | |
| 218 | bitcoind.generate_block(6, wait_for_mempool=1) |
nothing calls this directly
no test coverage detected