### Starting Fiber/CKB Nodes - Shell Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/dev/README.md Executes the script to start the development node setup for Fiber (FNN) and CKB. It automatically initializes the dev chain if it hasn't been set up previously, providing a ready environment for development and testing. ```Shell ./tests/nodes/start.sh ``` -------------------------------- ### Starting Fiber Test Nodes (Shell) Source: https://github.com/nervosnetwork/fiber/blob/develop/tests/bruno/e2e/open-use-close-a-channel/README.md This command executes a shell script to start the network nodes required for running the end-to-end fiber channel tests. It sets up the necessary environment for the test scenario described. ```Shell ./tests/nodes/start.sh ``` -------------------------------- ### Starting Fiber Node (Shell) Source: https://github.com/nervosnetwork/fiber/blob/develop/README.md Launches the FNN executable with necessary configurations. It sets the required environment variable FIBER_SECRET_KEY_PASSWORD for encrypting the wallet key and optionally sets the RUST_LOG level for logging verbosity. It also specifies the configuration file (-c) and the data directory (-d). Replace 'YOUR_PASSWORD' and potentially 'info' with desired values. ```Shell FIBER_SECRET_KEY_PASSWORD='YOUR_PASSWORD' RUST_LOG='info' ./fnn -c config.yml -d . ``` -------------------------------- ### Starting Fiber/CKB Nodes Cleanly - Shell Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/dev/README.md Executes the script to start the development node setup, explicitly setting the `REMOVE_OLD_STATE` environment variable to 'y'. This command removes any old state before starting, which is useful for development when database schemas or other states might change and require a clean environment. ```Shell REMOVE_OLD_STATE=y ./tests/nodes/start.sh ``` -------------------------------- ### Building Fiber Node Binary (Shell) Source: https://github.com/nervosnetwork/fiber/blob/develop/README.md Compiles the Fiber Network Node project using Cargo in release mode. This command is used to build an optimized executable binary from the source code. It requires Rust and Cargo to be installed on the system. ```Shell cargo build --release ``` -------------------------------- ### Running API Tests with Bruno - Shell Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/dev/README.md Changes the current directory to the Bruno test suite location (`tests/bruno`) and then executes the Bruno CLI via `npm exec`. This command runs a specific end-to-end test collection (`e2e/open-use-close-a-channel`) against the configured test environment, useful for verifying core functionality of the running dev chain setup. ```Shell cd tests/bruno npm exec -- @usebruno/cli run e2e/open-use-close-a-channel -r --env test ``` -------------------------------- ### Example Payment Preimage Output Bash Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/testnet-nodes.md Example output from the openssl command, showing a randomly generated 32-byte (64 hex characters) number prefixed with '0x'. This value is used when creating a new invoice. ```bash 0xbc03e507befb33cfd5953a2e7046428e69cb8f0ade65c05d3661128aa4b4fff9 ``` -------------------------------- ### Setting Up Node Directory (Shell) Source: https://github.com/nervosnetwork/fiber/blob/develop/README.md Creates a dedicated directory for the FNN instance, copies the compiled binary and testnet configuration file into it, and changes the current directory to the newly created one. This prepares the workspace for running the node. Ensure the paths for the binary and config file are correct. ```Shell mkdir /folder-to/my-fnn // if you are using the released binary, replace target/release/fnn with the path of released binary cp target/release/fnn /folder-to/my-fnn cp config/testnet/config.yml /folder-to/my-fnn cd /folder-to/my-fnn ``` -------------------------------- ### Setting Up CKB Account Key - CKB CLI - Bash Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/testnet-nodes.md Sets up a directory structure for the local node, uses `ckb-cli` to create a new CKB account and export its extended private key based on a specific lock-arg, extracts the first line (private key) from the exported key file, saves it to a designated location (`testnet-fnn/nodeA/ckb/key`), sets file permissions to 600 for security, and verifies the key information using `ckb-cli`. Requires `ckb-cli` to be installed and accessible in the current directory or PATH. ```bash mkdir -p testnet-fnn/nodeA/ckb ./ckb-cli account new ./ckb-cli account export --lock-arg 0xcc015401df73a3287d8b2b19f0cc23572ac8b14d --extended-privkey-path exported-key head -n 1 ./exported-key > testnet-fnn/nodeA/ckb/key chmod 600 testnet-fnn/nodeA/ckb/key # check nodeA key ./ckb-cli util key-info --privkey-path testnet-fnn/nodeA/ckb/key ``` -------------------------------- ### Running Cross-Chain Hub E2E Tests (Shell) Source: https://github.com/nervosnetwork/fiber/blob/develop/tests/bruno/e2e/cross-chain-hub/README.md This command executes the end-to-end tests for the cross-chain hub using the Bruno CLI tool. It specifies the test collection path and the 'test' environment configuration. ```shell npm exec -- @usebruno/cli run e2e/cross-chain-hub -r --env test ``` -------------------------------- ### Starting Fiber Node - Fiber - Bash Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/testnet-nodes.md Sets the `RUST_LOG` environment variable to 'info' for detailed logging, executes the Fiber node binary (`fnn`), specifying the configuration file (`testnet-fnn/nodeA/config.yml`) and data directory (`testnet-fnn/nodeA`). It redirects standard output and error to a log file (`testnet-fnn/nodeA/a.log`) and runs the command in the background. Requires the `fnn` binary, config file, and data directory to be prepared. ```bash RUST_LOG=info ./fnn -c testnet-fnn/nodeA/config.yml -d testnet-fnn/nodeA > testnet-fnn/nodeA/a.log 2>&1 & ``` -------------------------------- ### (Re)Initializing Development Chain - Shell Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/dev/README.md Runs the script to initialize or re-initialize the CKB development chain. This process can include transferring default balances from a designated account and deploying necessary contracts. The optional `-f` parameter can be used to forcefully clean all old state before initialization, useful for resetting the dev chain to a pristine state. ```Shell ./tests/deploy/init-dev-chain.sh [-f] ``` -------------------------------- ### Fiber RPC list_channels Response JSON Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/testnet-nodes.md Example JSON response listing the details of channels associated with the queried peer. Includes channel state (e.g., CHANNEL_READY), IDs, balances (local_balance, remote_balance), and other properties. ```json {"jsonrpc":"2.0","result":{"channels":[{"channel_id":"0x26ce85d57fb4a1a826cbf4862358862317a83b775090625550d8be12c6ce9569","is_public":true,"channel_outpoint":"0x9bb2a8a4bebaf793a235ba2ec87051ae0018b58736b6741df74009ca8101cb8d00000000","peer_id":"QmXen3eUHhywmutEzydCsW4hXBoeVmdET2FJvMX69J1Eo","funding_udt_type_script":null,"state":{"state_name":"CHANNEL_READY","state_flags":[]},"local_balance":"0xa32aef600","offered_tlc_balance":"0x0","remote_balance":"0x460913c00","received_tlc_balance":"0x0","latest_commitment_transaction_hash":"0x18ef541a5a195c0ea4715a7783964b3c4be8fba6bd25542e626f91ef1673e3e4","created_at":"0x195892d237f","enabled":true,"tlc_expiry_delta":"0x5265c00","tlc_fee_proportional_millionths":"0x3e8"}]},"id":3} ``` -------------------------------- ### Running Bruno E2E Channel Test (Shell) Source: https://github.com/nervosnetwork/fiber/blob/develop/tests/bruno/e2e/open-use-close-a-channel/README.md This command sequence changes the directory to the Bruno test collection location and then executes the specified Bruno collection using the Bruno CLI. It runs the end-to-end test scenario for opening, using, and closing a fiber channel in the 'test' environment. ```Shell cd tests/bruno npm exec -- @usebruno/cli run e2e/open-use-close-a-channel -r --env test ``` -------------------------------- ### Fiber RPC connect_peer Success Response JSON Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/testnet-nodes.md Example JSON response indicating a successful network connection request initiated by the connect_peer RPC call. A 'result' of null signifies success. ```json {"jsonrpc":"2.0","result":null,"id":1} ``` -------------------------------- ### Importing CKB Wallet Key (Shell) Source: https://github.com/nervosnetwork/fiber/blob/develop/README.md Sets up a directory for CKB keys, exports a private key using the ckb-cli tool, extracts only the private key part from the exported file, saves it to 'ckb/key', and then removes the temporary export file. This provides the private key required by the FNN's built-in wallet for signing funding transactions. Replace with your actual lock argument. ```Shell mkdir ckb ckb-cli account export --lock-arg --extended-privkey-path ./ckb/exported-key // ckb-cli exports master private key and chain code, FNN only needs the private key part head -n 1 ./ckb/exported-key > ./ckb/key // the exported key file can be deleted after the private key is extracted rm ./ckb/exported-key ``` -------------------------------- ### Fiber RPC new_invoice Success Response JSON Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/testnet-nodes.md Example JSON response confirming the successful creation of a new invoice. Contains the invoice address string and detailed invoice data including amount, currency, timestamp, payment hash, and payee public key. ```json {"jsonrpc":"2.0","result":{"invoice_address":"fibt1000000001peseucdphcxgfw0pnm6vk3uftyc36dakyjchs0p0unk9gaug0h36uhafww9pvy38gcesad084rx48xgx9xts49yp9fn87yfchld3l3qu5n0pfzvvy8c9g7dksrcxyrtk3hymspezmvtx4vg5v6uvt6tyxmq5uhrfejpk0j6wue9ef2pa8mzmrgqaz3wucutujtjcmq2x8f36faxuctg62ny73mhaj7rpwqe0ns0wp5wr4tku7qcl9r4a3swluvd2jqqwmsl7wsz4cwvhhe7p8tr7hz5qkqwr3r38hukckqzjtmntd8zrz0ywux4u8df005hl76thzsp9hz7dyefzk4mqhx4x9el98zjzmhcveqpfeur79","invoice":{"currency":"Fibt","amount":"0x5f5e100","signature":"0e1b101f1e0e100215180e0c1717191e01070b031e1702140016000e0311031107171c1618160002120b1b130b0d070203020f040e1c06151c070d090f0f14171f1e1a0b170210010517021e0d0419090216151b001706150605191f05070212021b17180c190001","data":{"timestamp":"0x1958944fa64","payment_hash":"0xafb604f74c28009732ed4c82983cf1efaddf62ee36442f360fb4a8c79b845432","attrs":[{"Description":"test invoice generated by node2"},{"ExpiryTime":{"secs":3600,"nanos":0}},{"HashAlgorithm":"sha256"},{"PayeePublicKey":"0291a6576bd5a94bd74b27080a48340875338fff9f6d6361fe6b8db8d0d1912fcc"}]}}},"id":4} ``` -------------------------------- ### Fiber RPC open_channel Success Response JSON Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/testnet-nodes.md Example JSON response indicating the successful initiation of an open_channel request. The 'result' contains a temporary channel ID that identifies this specific channel proposal. ```json {"jsonrpc":"2.0","result":{"temporary_channel_id":"0x30089ec4c8ce1e1d4930220c2bff856eec7ab44550e15b76d62489fd42eaafe8"},"id":2} ``` -------------------------------- ### Custom Records Parameter Example - JSON Source: https://github.com/nervosnetwork/fiber/blob/develop/src/rpc/README.md Example illustrating the structure and data format for the `custom_records` parameter used in the `send_payment_with_router` RPC method. It shows a JSON object representing a map where keys are 32-bit unsigned integers (shown as hex strings) and values are byte vectors (shown as hex strings). ```json { "0x1": "0x01020304", "0x2": "0x05060708", "0x3": "0x090a0b0c", "0x4": "0x0d0e0f10010d090a0b0c" } ``` -------------------------------- ### Migrating Node Storage (Shell) Source: https://github.com/nervosnetwork/fiber/blob/develop/README.md Runs the fnn-migrate utility to upgrade the storage format of the node's data directory. This tool is used when upgrading FNN versions that have incompatible storage formats but you wish to preserve existing channel states. It attempts to convert the data in place to the new format. Ensure the node is stopped before running this command. ```Shell fnn-migrate -p /folder-to/my-fnn/fiber/store ``` -------------------------------- ### Example Payment Custom Records JSON Source: https://github.com/nervosnetwork/fiber/blob/develop/src/rpc/README.md Illustrates the expected JSON format for the `custom_records` field within payment data. It shows how arbitrary key-value pairs are represented using hex-encoded `u32` keys and hex-encoded `Vec` values. ```json "custom_records": { "0x1": "0x01020304", "0x2": "0x05060708", "0x3": "0x090a0b0c", "0x4": "0x0d0e0f10010d090a0b0c" } ``` -------------------------------- ### Example custom_records Parameter JSON Source: https://github.com/nervosnetwork/fiber/blob/develop/src/rpc/README.md This JSON snippet illustrates the required structure for the `custom_records` parameter used in the `send_payment` RPC method. It shows a map where keys are hexadecimal representations of `u32` record types and values are hexadecimal representations of `Vec` serialized data. ```json { "0x1": "0x01020304", "0x2": "0x05060708", "0x3": "0x090a0b0c", "0x4": "0x0d0e0f10010d090a0b0c" } ``` -------------------------------- ### Removing Node Storage (Shell) Source: https://github.com/nervosnetwork/fiber/blob/develop/README.md Deletes the entire storage directory used by the Fiber Network Node. This action is typically performed during an incompatible upgrade when preserving channel state is not possible or desired. **Warning**: This will result in the loss of all channel data and associated funds in those channels. Ensure you have closed channels or backed up data if needed. ```Shell rm -rf /folder-to/my-fnn/fiber/store ``` -------------------------------- ### Copying Node Configuration - Fiber - Bash Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/testnet-nodes.md Copies the testnet configuration file (`config.yml`) from its source location (`config/testnet/`) to the designated directory for the local Fiber node (`testnet-fnn/nodeA`). This prepares the node directory with the necessary configuration for startup. Assumes the source config file exists. ```bash cp config/testnet/config.yml testnet-fnn/nodeA ``` -------------------------------- ### Downloading Fiber Node Binary - Fiber - Bash Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/testnet-nodes.md Creates a temporary directory, downloads the specified version of the Fiber node binary (`fnn`) archive for macOS (Apple silicon) from the GitHub releases page, and extracts the contents of the archive. Requires `wget` and `tar` commands to be available. ```bash mkdir tmp && cd tmp wget https://github.com/nervosnetwork/fiber/releases/download/v0.4.0/fnn_v0.4.0-x86_64-darwin-portable.tar.gz tar xzvf fnn_v0.4.0-x86_64-darwin-portable.tar.gz ``` -------------------------------- ### Opening CKB Channel via Fiber RPC Bash Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/testnet-nodes.md Initiates the process of opening a CKB channel with a specified peer (node1), funding it with a certain amount (500 CKB in hex shannons), and setting it as public. Requires node1 to accept the channel based on its configuration. ```bash curl -s --location 'http://127.0.0.1:8227' --header 'Content-Type: application/json' --data '{ "id": 2, "jsonrpc": "2.0", "method": "open_channel", "params": [ { "peer_id": "QmXen3eUHhywmutEzydCsW4hXBoeVmdET2FJvMX69J1Eo", "funding_amount": "0xba43b7400", "public": true } ] }' ``` -------------------------------- ### Querying Node1 Channels via Fiber RPC Bash Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/testnet-nodes.md Queries the status and details of channels specifically between node1 and node2 from node1's perspective using the list_channels RPC method. Useful for verifying the state and balances of the channel on node1's side before attempting a payment. ```bash curl -s --location 'http://18.162.235.225:8227' --header 'Content-Type: application/json' --data '{ "id": 5, "jsonrpc": "2.0", "method": "list_channels", "params": [ { "peer_id": "QmbKyzq9qUmymW2Gi8Zq7kKVpPiNA1XUJ6uMvsUC4F3p89" } ] }' ``` -------------------------------- ### Generating Invoice via Fiber RPC Bash Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/testnet-nodes.md Calls the new_invoice RPC method on a specific node (node2) to create a payment request (invoice). Specifies the amount (1 CKB), currency, description, expiry, final CLTV delta, payment preimage, and hash algorithm. ```bash curl -s --location 'http://18.163.221.211:8227' --header 'Content-Type: application/json' --data '{ "id": 4, "jsonrpc": "2.0", "method": "new_invoice", "params": [ { "amount": "0x5f5e100", "currency": "Fibt", "description": "test invoice generated by node2", "expiry": "0xe10", "final_cltv": "0x28", "payment_preimage": "0xbc03e507befb33cfd5953a2e7046428e69cb8f0ade65c05d3661128aa4b4fff9", "hash_algorithm": "sha256" } ] }' ``` -------------------------------- ### Querying Channels via Fiber RPC Bash Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/testnet-nodes.md Queries the status and details of channels established with a specific peer (node1) using the list_channels RPC method. Useful for checking the state, balances, and other properties of existing channels. ```bash curl -s --location 'http://127.0.0.1:8227' --header 'Content-Type: application/json' --data '{ "id": 3, "jsonrpc": "2.0", "method": "list_channels", "params": [ { "peer_id": "QmXen3eUHhywmutEzydCsW4hXBoeVmdET2FJvMX69J1Eo" } ] }' ``` -------------------------------- ### Sending Payment via Nervos Fiber RPC - Bash Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/testnet-nodes.md This snippet demonstrates how to initiate a payment on a Nervos Fiber node using a curl command to send an RPC request. It requires a running Fiber node accessible at http://127.0.0.1:8227 and a valid payment invoice. ```bash curl -s --location 'http://127.0.0.1:8227' --header 'Content-Type: application/json' --data '{ "id": 6, "jsonrpc": "2.0", "method": "send_payment", "params": [ { "invoice": "fibt1000000001peseucdphcxgfw0pnm6vk3uftyc36dakyjchs0p0unk9gaug0h36uhafww9pvy38gcesad084rx48xgx9xts49yp9fn87yfchld3l3qu5n0pfzvvy8c9g7dksrcxyrtk3hymspezmvtx4vg5v6uvt6tyxmq5uhrfejpk0j6wue9ef2pa8mzmrgqaz3wucutujtjcmq2x8f36faxuctg62ny73mhaj7rpwqe0ns0wp5wr4tku7qcl9r4a3swluvd2jqqwmsl7wsz4cwvhhe7p8tr7hz5qkqwr3r38hukckqzjtmntd8zrz0ywux4u8df005hl76thzsp9hz7dyefzk4mqhx4x9el98zjzmhcveqpfeur79" } ] }' ``` -------------------------------- ### Open UDT Channel to Peer using cURL Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/testnet-nodes.md Initiates the process to open a new public UDT channel with a specified peer node. Requires the peer's ID, the funding amount (in hexadecimal), a flag for public visibility, and the UDT's type script details. ```bash curl -s --location 'http://127.0.0.1:8227' --header 'Content-Type: application/json' --data '{ "id": 2, "jsonrpc": "2.0", "method": "open_channel", "params": [ { "peer_id": "QmXen3eUHhywmutEzydCsW4hXBoeVmdET2FJvMX69XJ1Eo", "funding_amount": "0x2540be400", "public": true, "funding_udt_type_script": { "code_hash": "0x1142755a044bf2ee358cba9f2da187ce928c91cd4dc8692ded0337efa677d21a", "hash_type": "type", "args": "0x878fcc6f1f08d48e87bb1c3b3d5083f23f8a39c5d5c764f253b55b998526439b" } } ] }' ``` ```json {"jsonrpc":"2.0","result":{"temporary_channel_id":"0xa3137338377b67ea90c2f2c15b7d60ad27b3e891095f4b093772d7db3aa79344"},"id":2} ``` -------------------------------- ### Send Payment Request using cURL Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/testnet-nodes.md Initiates a payment from nodeA to node2 using a previously generated invoice string. The invoice contains all necessary information to route the payment through the channel network. ```bash curl -s --location 'http://127.0.0.1:8227' --header 'Content-Type: application/json' --data '{ "id": 6, "jsonrpc": "2.0", "method": "send_payment", "params": [ { "invoice": "fibt1000000001px88ja42xcmczxzat8lhtuq9f29ga8x244qk737nl4r7lq8aw7y7puhjn6jp50xsd2c6ndfxkmn5wnl4z8clk7fej9trwx0gjlmtvnj2wqwlvcu0eekzqvtehlc42t8lpstmgc7ntskh5ef36f8hgvck8c9pescktlx05fpuaceews94kvyrvgf87gvd9wnmh86puzyz2vp6h6jppt8lsq5u8tc87y6szha9587f90dmlmwt5mtetxz9ekukxu6x7s2fyuuy2re0etzzksqnt8rtr5925qypz2224j5xf56nlscnmtvcvywdxg40hsy5w5xt40d5cdest3kvhqswfftfc3qqs7plhlk7m5n9hyzqws9qlxw2huurg7l6c4q9evyg7fljcl3cqh3h3ecpg3fue3cq4slpxapvc2uye6jl77sfcflc8jf8fvr4qwly9wxuyehqf573hu454qy92wqke0hdgrvm7y83sgspn4a29h69s7ucp4cedle" } ] }' ``` ```json {"jsonrpc":"2.0","result":{"payment_hash":"0x6a356ad088b704a9c53728029bd968e894daf5adab1da838bf06f6755239b005","status":"Created","created_at":"0x1958e7b66b5","last_updated_at":"0x1958e7b66b5","failed_error":null,"fee":"0x186a0"},"id":6} ``` -------------------------------- ### Connecting Peer Node via Fiber RPC Bash Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/testnet-nodes.md Establishes a network connection between the local Fiber node (nodeA) and a specified remote public node (node1) using the connect_peer RPC method. It sends a JSON-RPC request via curl to the local node's RPC endpoint. ```bash curl -s --location 'http://127.0.0.1:8227' --header 'Content-Type: application/json' --data '{ "id": 1, "jsonrpc": "2.0", "method": "connect_peer", "params": [ { "address": "/ip4/18.162.235.225/tcp/8119/p2p/QmXen3eUHhywmutEzydCsW4hXBoeVmdET2FJvMX69XJ1Eo" } ] }' ``` -------------------------------- ### Query Node1 Channels with Node2 Balances using cURL Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/testnet-nodes.md Queries channels between node1 and node2 to inspect their balances, specifically looking for UDT channels (where `funding_udt_type_script` is not null). This helps observe balance changes after payments. ```bash curl -s --location 'http://18.162.235.225:8227' --header 'Content-Type: application/json' --data '{ "id": 5, "jsonrpc": "2.0", "method": "list_channels", "params": [ { "peer_id": "QmbKyzq9qUmymW2Gi8Zq7kKVpPiNA1XUJ6uMvsUC4F3p89" } ] }' ``` ```json {"local_balance":"0x172a2c63bb","remote_balance":"0x1e4a8445"} {"local_balance":"0x1748630df7","remote_balance":"0x13da09"} {"local_balance":"0xa38b9d","remote_balance":"0x1747d35c63"} {"local_balance":"0xc505f","remote_balance":"0x17486a97a1"} ``` -------------------------------- ### Generate New Invoice using cURL Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/testnet-nodes.md Requests a node to generate a new invoice for receiving a UDT payment. Specifies the amount, currency, description, expiry, final CLTV delta, a unique payment preimage, hash algorithm, and the UDT type script. ```bash curl -s --location 'http://18.163.221.211:8227' --header 'Content-Type: application/json' --data '{ "id": 4, "jsonrpc": "2.0", "method": "new_invoice", "params": [ { "amount": "0x5f5e100", "currency": "Fibt", "description": "test invoice generated by node2", "expiry": "0xe10", "final_cltv": "0x28", "payment_preimage": "0xf7d121b132b4f53bb8301591028b34fccc065f92161bb6e7d41cf6d32ad32a22", "hash_algorithm": "sha256", "udt_type_script": { "code_hash": "0x1142755a044bf2ee358cba9f2da187ce928c91cd4dc8692ded0337efa677d21a", "hash_type": "type", "args": "0x878fcc6f1f08d48e87bb1c3b3d5083f23f8a39c5d5c764f253b55b998526439b" } } ] }' ``` ```json {"jsonrpc":"2.0","result":{"invoice_address":"fibt1000000001px88ja42xcmczxzat8lhtuq9f29ga8x244qk737nl4r7lq8aw7y7puhjn6jp50xsd2c6ndfxkmn5wnl4z8clk7fej9trwx0gjlmtvnj2wqwlvcu0eekzqvtehlc42t8lpstmgc7ntskh5ef36f8hgvck8c9pescktlx05fpuaceews94kvyrvgf87gvd9wnmh86puzyz2vp6h6jppt8lsq5u8tc87y6szha9587f90dmlmwt5mtetxz9ekukxu6x7s2fyuuy2re0etzzksqnt8rtr5925qypz2224j5xf56nlscnmtvcvywdxg40hsy5w5xt40d5cdest3kvhqswfftfc3qqs7plhlk7m5n9hyzqws9qlxw2huurg7l6c4q9evyg7fljcl3cqh3h3ecpg3fue3cq4slpxapvc2uye6jl77sfcflc8jf8fvr4qwly9wxuyehqf573hu454qy92wqke0hdgrvm7y83sgspn4a29h69s7ucp4cedle","invoice":{"currency":"Fibt","amount":"0x5f5e100","signature":"161b1405170f18161b1e1c090c0a0a010a190409061c1b1a1107130413040f1a0204080504121212150f1b031b171a040417030102191d010a1317090f1f1c120e1909121b0d041b17101f071e1b020d170a151a15121d0d081d12151816171c0d000215190a1801","data":{"timestamp":"0x1958e785913","payment_hash":"0x6a356ad088b704a9c53728029bd968e894daf5adab1da838bf06f6755239b005","attrs":[{"Description":"test invoice generated by node2"},{"ExpiryTime":{"secs":3600,"nanos":0}},{"UdtScript":"0x550000001000000030000000310000001142755a044bf2ee358cba9f2da187ce928c91cd4dc8692ded0337efa677d21a0120000000878fcc6f1f08d48e87bb1c3b3d5083f23f8a39c5d5c764f253b55b998526439b"},{"HashAlgorithm":"sha256"},{"PayeePublicKey":"0291a6576bd5a94bd74b27080a48340875338fff9f6d6361fe6b8db8d0d1912fcc"}]}}},"id":4} ``` -------------------------------- ### Generating Random Payment Preimage Bash Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/testnet-nodes.md Uses the openssl command-line tool to generate a cryptographically secure, random 32-byte hexadecimal number. This is typically used as the payment preimage for creating invoices. ```bash # Generate a 32-byte random number and represent it in hexadecimal payment_preimage="0x$(openssl rand -hex 32)" echo $payment_preimage ``` -------------------------------- ### Query Channels with Peer using cURL Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/testnet-nodes.md Retrieves a list of channels established with a specific peer ID. Useful for checking channel status, balances, and other details after opening or before payment operations. ```bash curl -s --location 'http://127.0.0.1:8227' --header 'Content-Type: application/json' --data '{ "id": 3, "jsonrpc": "2.0", "method": "list_channels", "params": [ { "peer_id": "QmXen3eUHhywmutEzydCsW4hXBoeVmdET2FJvMX69XJ1Eo" } ] }' ``` ```json {"jsonrpc":"2.0","result":{"channels":[{"channel_id":"0x75dce35923a79086afd0f81b0134ac87619756b6c04a15669ce232aa7db142d8","is_public":true,"channel_outpoint":"0x8e133056792766e1fd34e870fb33990b58c4ebb9615526b38dacdf3686cf6d3f00000000","peer_id":"QmXen3eUHhywmutEzydCsW4hXBoeVmdET2FJvMX69XJ1Eo","funding_udt_type_script":{"code_hash":"0x1142755a044bf2ee358cba9f2da187ce928c91cd4dc8692ded0337efa677d21a","hash_type":"type","args":"0x878fcc6f1f08d48e87bb1c3b3d5083f23f8a39c5d5c764f253b55b998526439b"},"state":{"state_name":"CHANNEL_READY","state_flags":[]},"local_balance":"0x2540be400","offered_tlc_balance":"0x0","remote_balance":"0x0","received_tlc_balance":"0x0","latest_commitment_transaction_hash":"0x2b0b36c5db14778484358a4641bfe00a4f351660c280255ef8e8538898e399d0","created_at":"0x1958977b7be","enabled":true,"tlc_expiry_delta":"0x5265c00","tlc_fee_proportional_millionths":"0x3e8"}]},"id":3} ``` -------------------------------- ### Listing Public Testnet Node Addresses - Fiber - Bash Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/testnet-nodes.md Provides the multiaddr strings for two public Fiber testnet nodes. These addresses can be used to connect a local node to the testnet network. Each string includes the IP address, TCP port, and the node's Peer ID. ```bash "/ip4/18.162.235.225/tcp/8119/p2p/QmXen3eUHhywmutEzydCsW4hXBoeVmdET2FJvMX69XJ1Eo" "/ip4/18.163.221.211/tcp/8119/p2p/QmbKyzq9qUmymW2Gi8Zq7kKVpPiNA1XUJ6uMvsUC4F3p89" ``` -------------------------------- ### Shutdown Channel using cURL Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/testnet-nodes.md Requests to close an open channel with a peer. Requires the channel ID, a script for closing, and a fee rate for the on-chain transaction. This settles the final state of the off-chain channel on the CKB blockchain. ```bash curl -s --location 'http://127.0.0.1:8227' --header 'Content-Type: application/json' --data '{ "id": 9, "jsonrpc": "2.0", "method": "shutdown_channel", "params": [ { "channel_id": "0x75dce35923a79086afd0f81b0134ac87619756b6c04a15669ce232aa7db142d8", "close_script": { "code_hash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8", "hash_type": "type", "args": "0xcc015401df73a3287d8b2b19f0cc23572ac8b14d" }, "fee_rate": "0x3FC" } ] }' ``` ```json {"jsonrpc":"2.0","result":null,"id":9} ``` -------------------------------- ### Defining TxUpdate Message - Molecule Schema Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/specs/p2p-message.md Defines the TxUpdate message structure used by the channel initiator to begin the transaction construction protocol. It includes the channel identifier and the transaction data. ```Molecule Schema table TxUpdate { channel_id: Byte32, tx: Transaction, } ``` -------------------------------- ### AcceptChannel Message Structure (Molecule) Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/specs/p2p-message.md Defines the structure of the AcceptChannel message, sent by the receiver to accept a channel establishment request. It mirrors many fields from OpenChannel and includes the receiver's funding contribution, TLC limits, and public keys. ```Molecule table AcceptChannel { channel_id: Byte32, funding_amount: Uint128, max_tlc_value_in_flight: Uint128, max_tlc_number_in_flight: Uint64, min_tlc_value: Uint128, to_self_delay: Uint64, funding_pubkey: Byte33, tlc_basepoint: Byte33, payment_basepoint: Byte33, delayed_payment_basepoint: Byte33, first_per_commitment_point: Byte33, second_per_commitment_point: Byte33, next_local_nonce: Byte66, } ``` -------------------------------- ### Defining TxComplete Message - Molecule Schema Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/specs/p2p-message.md Defines the TxComplete message structure indicating the successful completion of the transaction construction process. It contains the channel identifier. ```Molecule Schema table TxComplete { channel_id: Byte32, } ``` -------------------------------- ### Sending Shutdown Channel RPC Request - Shell Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/testnet-nodes.md This `curl` command sends an RPC request to a local Fiber node (http://127.0.0.0:8227) to shut down a specific channel. It includes the channel ID, the script to use for closing (with code hash, hash type, and args), and a fee rate for the closing transaction. ```Shell curl -s --location 'http://127.0.0.1:8227' --header 'Content-Type: application/json' --data '{ "id": 9, "jsonrpc": "2.0", "method": "shutdown_channel", "params": [ { "channel_id": "0x26ce85d57fb4a1a826cbf4862358862317a83b775090625550d8be12c6ce9569", "close_script": { "code_hash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8", "hash_type": "type", "args": "0xcc015401df73a3287d8b2b19f0cc23572ac8b14d" }, "fee_rate": "0x3FC" } ] }' ``` -------------------------------- ### OpenChannel Message Structure (Molecule) Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/specs/p2p-message.md Defines the structure of the OpenChannel message, sent by the initiator to request channel establishment. It contains parameters like chain hash, channel ID, funding details, TLC limits, public keys, and channel flags. ```Molecule table OpenChannel { chain_hash: Byte32, channel_id: Byte32, funding_type_script: ScriptOpt, funding_amount: Uint128, funding_fee_rate: Uint64, commitment_fee_rate: Uint64, max_tlc_value_in_flight: Uint128, max_tlc_number_in_flight: Uint64, min_tlc_value: Uint128, to_self_delay: Uint64, funding_pubkey: Byte33, tlc_basepoint: Byte33, first_per_commitment_point: Byte33, second_per_commitment_point: Byte33, next_local_nonce: Byte66, channel_flags: Byte, } ``` -------------------------------- ### ChannelReady Message Structure (Molecule) Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/specs/p2p-message.md Defines the structure of the ChannelReady message, sent after the funding transaction is signed and broadcast. It signals that the channel is ready for use and contains only the channel ID. ```Molecule table ChannelReady { channel_id: Byte32, } ``` -------------------------------- ### Defining TxInitRBF Message - Molecule Schema Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/specs/p2p-message.md Defines the TxInitRBF message structure used by the channel initiator to request an RBF (Replace-By-Fee) operation for the funding transaction. It specifies the channel identifier and the desired new fee rate. ```Molecule Schema table TxInitRBF { channel_id: Byte32, fee_rate: Uint64, } ``` -------------------------------- ### Successful RPC Response - JSON Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/testnet-nodes.md This JSON object represents the standard successful response format for an RPC call. The `jsonrpc` field indicates the version, `result` being null signifies that the operation completed successfully without returning data, and `id` matches the request ID. ```JSON {"jsonrpc":"2.0","result":null,"id":9} ``` -------------------------------- ### Defining TxAbort Message - Molecule Schema Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/specs/p2p-message.md Defines the TxAbort message structure used by a node to terminate the transaction collaboration process before signature exchange. It includes the channel identifier and an optional message detailing the reason. ```Molecule Schema table TxAbort { channel_id: Byte32, message: Bytes, } ``` -------------------------------- ### Defining Shutdown Message - Molecule Schema Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/specs/p2p-message.md Defines the Shutdown message structure sent by either node to request mutual channel closure. It specifies the channel identifier, the script for distributing assets upon closure, and a fee rate. ```Molecule Schema table Shutdown { channel_id: Byte32, close_script: Script, fee_rate: Uint64, } ``` -------------------------------- ### Defining ClosingSigned Message - Molecule Schema Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/specs/p2p-message.md Defines the ClosingSigned message structure sent after completing pending TLCs to sign the close transaction. It includes the channel identifier and a partial signature for the transaction. ```Molecule Schema table ClosingSigned { channel_id: Byte32, partial_signature: Byte32, } ``` -------------------------------- ### TxSignatures Message Structure (Molecule) Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/specs/p2p-message.md Defines the structure of the TxSignatures message, used to exchange signatures for the funding transaction. It includes the channel ID, the funding transaction hash, and a vector of signed witnesses for the sender's inputs. ```Molecule table TxSignatures { channel_id: Byte32, tx_hash: Byte32, witnesses: BytesVec, } ``` -------------------------------- ### Defining AddTlc Message - Molecule Schema Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/specs/p2p-message.md Defines the AddTlc message structure used to initiate a payment operation or forward a payment request via a Time Locked Contract (TLC). It includes channel ID, unique TLC ID, amount, payment hash, and expiry timestamp. ```Molecule Schema table AddTlc { channel_id: Byte32, tlc_id: Uint64, amount: Uint128, payment_hash: Byte32, expiry: Uint64, } ``` -------------------------------- ### CommitmentSigned Message Structure (Molecule) Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/specs/p2p-message.md Defines the structure of the CommitmentSigned message, exchanged after commitment transaction signing. It contains the channel ID, a partial signature for the 2-2 Schnorr multisig, and the next local nonce for future partial signatures. ```Molecule table CommitmentSigned { channel_id: Byte32, partial_signature: Byte32, next_local_nonce: Byte66, } ``` -------------------------------- ### Defining TxAckRBF Message - Molecule Schema Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/specs/p2p-message.md Defines the TxAckRBF message structure used by the channel responder to agree to an RBF operation initiated by TxInitRBF. It only contains the channel identifier. ```Molecule Schema table TxAckRBF { channel_id: Byte32, } ``` -------------------------------- ### Defining RevokeAndAck Message - Molecule Schema Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/specs/p2p-message.md Defines the RevokeAndAck message structure used to reveal the previous commitment transaction secret and acknowledge a new state after receiving and verifying a CommitmentSigned message. It contains the channel ID, previous secret, next commitment point, and next local nonce. ```Molecule Schema table RevokeAndAck { channel_id: Byte32, per_commitment_secret: Byte32, next_per_commitment_point: Byte33, next_local_nonce: Byte66, } ``` -------------------------------- ### Defining RemoveTlc Messages - Molecule Schema Source: https://github.com/nervosnetwork/fiber/blob/develop/docs/specs/p2p-message.md Defines the messages and structures used by the AddTlc recipient to remove a TLC. RemoveTlc specifies the channel and TLC ID and reason (Fulfill or Fail). RemoveTlcReason is a union covering fulfillment or failure states. RemoveTlcFulfill contains the payment preimage, while RemoveTlcFail contains an error code. ```Molecule Schema table RemoveTlc { channel_id: Byte32, tlc_id: Uint64, reason: RemoveTlcReason } union RemoveTlcReason { RemoveTlcFulfill, RemoveTlcFail, } struct RemoveTlcFulfill { payment_preimage: Byte32, } struct RemoveTlcFail { error_code: Uint32, } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.