@@ -317,6 +317,49 @@ if [[ $1 == "swapserver_refund" ]]; then
317317fi
318318
319319
320+ if [[ $1 == " swapserver_server_skip_onchain_funding" ]]; then
321+ # Alice starts reverse-swap with Bob.
322+ # Alice sends hold-HTLCs via LN. Bob does NOT fund locking script onchain.
323+ # After a while, Alice requests Bob to force-close chan, and Bob does.
324+ # Alice will broadcast HTLC-timeout tx to reclaim the swap amount from Bob's commitment tx.
325+ $bob setconfig test_swapserver_skip_onchain_funding true
326+ wait_for_balance alice 1
327+ echo " alice opens channel"
328+ bob_node=$( $bob nodeid)
329+ channel=$( $alice open_channel $bob_node 0.15 --password=' ' )
330+ chan_funding_txid=$( echo " $channel " | cut -d " :" -f 1)
331+ chan_funding_outidx=$( echo " $channel " | cut -d " :" -f 2)
332+ new_blocks 3
333+ wait_until_channel_open alice
334+ echo " alice initiates swap"
335+ dryrun=$( $alice reverse_swap 0.02 dryrun)
336+ onchain_amount=$( echo $dryrun | jq -r " .onchain_amount" )
337+ # Alice starts a reverse-swap, but will time out waiting for Bob's swap-funding-tx to appear in mempool.
338+ $alice setconfig timeout 10
339+ set +e
340+ swap=$( $alice reverse_swap 0.02 $onchain_amount )
341+ set -e
342+ $alice unsetconfig timeout
343+ # After a while, Alice gets impatient and gets Bob to close the channel.
344+ new_blocks 20
345+ $alice request_force_close $channel
346+ wait_until_spent $chan_funding_txid $chan_funding_outidx
347+ new_blocks 1
348+ wait_until_channel_closed alice
349+ ctx_id=$( $alice list_channels | jq -r " .[0].closing_txid" )
350+ # need more blocks to reach CLTV of HTLC-output in ctx
351+ new_blocks 130
352+ if [ $TEST_ANCHOR_CHANNELS = True ] ; then
353+ htlc_output_index=3 # FIXME index depends on Alice not using MPP
354+ else
355+ htlc_output_index=1
356+ fi
357+ wait_until_spent $ctx_id $htlc_output_index
358+ new_blocks 1
359+ wait_for_balance alice 0.997
360+ fi
361+
362+
320363if [[ $1 == " lnwatcher_waits_until_fees_go_down" ]]; then
321364 # Alice sends two HTLCs to Bob (one for small invoice, one for large invoice), which Bob will hold.
322365 # Alice requests Bob to force-close the channel, while the HTLCs are pending. Bob force-closes.
0 commit comments