From 781ec92606ce0ed1b99490f8e6082ca36151a39d Mon Sep 17 00:00:00 2001 From: Shreerang Kale Date: Mon, 28 Oct 2024 16:13:40 +0530 Subject: [PATCH] Add instructions to get all active swap channels based on ledger channel ID --- testnet-nitro-node.md | 76 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 74 insertions(+), 2 deletions(-) diff --git a/testnet-nitro-node.md b/testnet-nitro-node.md index 0d91680..74cb635 100644 --- a/testnet-nitro-node.md +++ b/testnet-nitro-node.md @@ -587,6 +587,80 @@ Perform swaps using a swap channel created with another Nitro node over the mirr ### Performing swaps +* Get all active swap channels for a specific mirrored ledger channel + + * To get mirrored ledger channels: + + ```bash + laconic-so deployment --dir l2-nitro-deployment exec nitro-rpc-client "nitro-rpc-client get-all-ledger-channels -p 4005 -h nitro-node" + + # Example output: + # [ + # { + # "ID": "0xb34210b763d4fdd534190ba11886ad1daa1e411c87be6fd20cff74cd25077c46", + # "Status": "Open", + # "Balances": [ + # { + # "AssetAddress": "0xa4351114dae1abeb2d552d441c9733c72682a45d", + # "Me": "0x075400039e303b3fb46c0cff0404c5fa61947c05", + # "Them": "0xf0e6a85c6d23aca9ff1b83477d426ed26f218185", + # "MyBalance": 1000n, + # "TheirBalance": 1000n + # }, + # { + # "AssetAddress": "0x314e43f9825b10961859c2a62c2de6a765c1c1f1", + # "Me": "0x075400039e303b3fb46c0cff0404c5fa61947c05", + # "Them": "0xf0e6a85c6d23aca9ff1b83477d426ed26f218185", + # "MyBalance": 1000n, + # "TheirBalance": 1000n + # } + # ], + # "ChannelMode": "Open" + # } + # ] + ``` + + * Export ledger channel ID: + + ```bash + export LEDGER_CHANNEL_ID= + ``` + + * To get swap channels for a ledger channel: + + ```bash + laconic-so deployment --dir l2-nitro-deployment exec nitro-rpc-client "nitro-rpc-client get-swap-channels-by-ledger $LEDGER_CHANNEL_ID -p 4005 -h nitro-node" + # Example Output: + # [ + # { + # ID: '0x1dbd58d314f123f4b0f4147eee7fd92fa523ba7082d8a75b846f6d1189e2f0e9', + # Status: 'Open', + # Balances: [ + # { + # AssetAddress: '0xa4351114dae1abeb2d552d441c9733c72682a45d', + # Me: '0x075400039e303b3fb46c0cff0404c5fa61947c05', + # Them: '0xd0ea8b27591b1d070cccd4d30b8d408fe794fdfc', + # MyBalance: 100, + # TheirBalance: 100n + # }, + # { + # AssetAddress: '0x314e43f9825b10961859c2a62c2de6a765c1c1f1', + # Me: '0x075400039e303b3fb46c0cff0404c5fa61947c05', + # Them: '0xd0ea8b27591b1d070cccd4d30b8d408fe794fdfc', + # MyBalance: 100, + # TheirBalance: 100 + # } + # ] + # } + # ] + ``` + + * Export swap channel ID: + + ```bash + export SWAP_CHANNEL_ID= + ``` + * One of the participants can initiate the swap and other one will either accept it or reject it * For initiating the swap: @@ -610,8 +684,6 @@ Perform swaps using a swap channel created with another Nitro node over the mirr * For receiving the swap - * Note: The party receiving the swaps will need the swap channel ID from swap channel creator for responding to swaps - * Get the pending swap: ```bash