Transact on-chain coins for off-chain via submarine swap-in LND
How to do this by using connected NODE on-chain funds and BOS (balances of satoshis)
What is the goal we want to achieve? Suppose we have a LND lightning node, with a channel open to LOOP node. This channel has decreased outbound liquidity and you want to refill such liquidity using on-chain funds you have on your local on-chain node’s wallet. We made such a test and reported below the commands and outputs. The addresses and real data are partially shown or masked.
Get Peers
First of all, check out your peers to find your LOOP peer and check if the outbound liquidity needs to be refilled.
bos peers
this will return a list of peers. Just check out your LOOP
now run, where LOOP is the <peername> you got by the previsous command.
Create pending swap-in
bos swap-in 0.01 --in LOOP
if you omit the amount, the default of 1M Sats gets used, like in the below example
dev@lnbits00:~$ bos swap-in --in LOOP
evaluating_connectivity: true
amount_paid_for_api_key: 0.00000001
service_api_key: a2686d616361726f6f6e58810201046c73617402420000ae31f2a398fa5726413334fbe735ea0819e354c5c6caaad422bd2874ad0c980fa8b41e3af7817ac3611ef8bc518da9d537XXXX
swap:
send_to_address: bc1qwzh0hgt9526jsvlhhxc5kx3guw8wvg70cck6z45XXXX
send_exact_amount: 0.01000000
send_to_qr:
"""
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
█ ▄▄▄▄▄ █▀█ █▄█▄▀█▄▀▄▀ ▄ █▀ █ ▄▄▄▄▄ █
█ █ █ █▀▀▀█ ▀█ ▀▀▄▄█▄▄██▀ █ █ █ █
█ █▄▄▄█ █▀ █▀▀█▄▀█▀▀▄ ▀▄▄ ▄▄▀▀█ █▄▄▄█ █
█▄▄▄▄▄▄▄█▄▀ ▀▄█▄▀▄█▄█▄▀▄▀ █▄█▄█▄▄▄▄▄▄▄█
"""
swap_service_fee: 1874
refund_recovery_secret: ac71636c61696d5f707269766174655f6b6579f770636c61696d5f7075626c69635f6b657978423032323263613661663239656365326138383961303366613739316665333138316633306166633932323062633836633331666437623262613739656339646533646c6578XXXXXXX
timing:
earliest_completion: in 10 minutes
refund_available: in 7 days
Fund the swap-in with local onchain coins
Now you can use the funds of the connected node to fund the swap transaction (beware that in the following command, the amount is in Sats). Amount must match with above command requirement and the destination address as well. The command returns the signed swap-in funding transaction
dev@lnbits00:~$ bos fund bc1qwzh0hgt9526jsvlhhxc5kx3guw8wvg70cck6z45XXXX 1000000
send_to:
-
bc1qwzh0hgt9526jsvlhhxc5kx3guw8wvg70cck6z45846fgw6mnl4jsh2ac8s: 0.01000000
requested_fee_rate: 2.352
change: 0.08898669
sum_of_outputs: 0.09898669
spending_utxos:
- 0697845784c71ce770feeacd77b560506d810e690dc82c8cd521d051accc8c77:1
fee_tokens_per_vbyte: 2.01
signed_transaction: 02000000000101778cccac51d021d58c2cc80d690e816d5060b577cdeafe70e71cc784578497060100000000ffffffff0240420f000000000022002070aefba165a2b52833f7b9b14b1a28e38ee623cfc62da15687ae92876b73fd656dc88700000000002251208b5b74bf88f40ea884786b0934abc74fc95fa7ab6e479ba5042c488fa0dccf2301406e7e31bf15fbda19601cf2dcac0962e241387c817c9f217aa9571ae84bd565d2b0b21f158b0b5d384ca54e13c32911513d44091104bbd85d821960264df1490500000000
Now publish the transaction by broadcasting it to the network.
bos broadcast <tx>
dev@lnbits00:~$ bos broadcast 02000000000101778cccac51d021d58c2cc80d690e816d5060b577cdeafe70e71cc784578497060100000000ffffffff0240420f000000000022002070aefba165a2b52833f7b9b14b1a28e38ee623cfc62da15687ae92876b73fd656dc88700000000002251208b5b74bf88f40ea884786b0934abc74fc95fa7ab6e479ba5042c488fa0dccf2301406e7e31bf15fbda19601cf2dcac0962e241387c817c9f217aa9571ae84bd565d2b0b21f158b0b5d384ca54e13c32911513d44091104bbd85d821960264df1490500000000
transaction_id: 98178e3060cde5d0843380bb24daab9d3216ce708f4092f90cc2039a1798999d
broadcast_transaction_at_height: 880793
transaction_confirmed_in_block: 880794
After that has been done, in the command above you will get the following additional lines
waiting_for_confirmation_of_tx: 98178e3060cde5d0843380bb24daab9d3216ce708f4092f90cc2039a1798999d
swap_successful:
completed: Today at 7:09 PM
received_offchain: 0.00998126
service_fee_paid: 0.00001874
Swap-in achieved
Now the channel situation is now:
As you can see the outbound side has increased by the corresponding amount. The price paid was 1874 Sats (+ transaction miner feees). So you got the result with few commands at the command line on the node itself.