# Fiber Network Node RPC
The RPC module provides a set of APIs for developers to interact with FNN. Please note that APIs are not stable yet and may change in the future.
Allowing arbitrary machines to access the JSON-RPC port (using the `rpc.listening_addr` configuration option) is **dangerous and strongly discouraged**. Please strictly limit the access to only trusted machines.
You may refer to the e2e test cases in the `tests/bruno/e2e` directory for examples of how to use the RPC.
* [RPC Methods](#rpc-methods)
* [Module Cch](#module-cch)
* [Method `send_btc`](#cch-send_btc)
* [Method `receive_btc`](#cch-receive_btc)
* [Method `get_receive_btc_order`](#cch-get_receive_btc_order)
* [Module Channel](#module-channel)
* [Method `open_channel`](#channel-open_channel)
* [Method `accept_channel`](#channel-accept_channel)
* [Method `list_channels`](#channel-list_channels)
* [Method `commitment_signed`](#channel-commitment_signed)
* [Method `add_tlc`](#channel-add_tlc)
* [Method `remove_tlc`](#channel-remove_tlc)
* [Method `shutdown_channel`](#channel-shutdown_channel)
* [Method `update_channel`](#channel-update_channel)
* [Method `send_payment`](#channel-send_payment)
* [Method `get_payment`](#channel-get_payment)
* [Module Graph](#module-graph)
* [Method `graph_nodes`](#graph-graph_nodes)
* [Method `graph_channels`](#graph-graph_channels)
* [Module Config](#module-config)
* [Module Mod](#module-mod)
* [Module Invoice](#module-invoice)
* [Method `new_invoice`](#invoice-new_invoice)
* [Method `parse_invoice`](#invoice-parse_invoice)
* [Method `get_invoice`](#invoice-get_invoice)
* [Module Info](#module-info)
* [Method `node_info`](#info-node_info)
* [Module Peer](#module-peer)
* [Method `connect_peer`](#peer-connect_peer)
* [Method `disconnect_peer`](#peer-disconnect_peer)
* [Module Utils](#module-utils)
* [RPC Types](#rpc-types)
* [Type `Channel`](#type-channel)
* [Type `ChannelInfo`](#type-channelinfo)
* [Type `InvoiceStatus`](#type-invoicestatus)
* [Type `NodeInfo`](#type-nodeinfo)
* [Type `RemoveTlcReason`](#type-removetlcreason)
* [Type `UdtArgInfo`](#type-udtarginfo)
* [Type `UdtCellDep`](#type-udtcelldep)
* [Type `UdtCfgInfos`](#type-udtcfginfos)
* [Type `UdtScript`](#type-udtscript)
## RPC Modules
### Module `Cch`
RPC module for cross chain hub demonstration.
This is the seccond line
#### Method `send_btc`
Send BTC to a address.
##### Params
* `btc_pay_req` - String, Bitcoin payment request string
* `currency` - Currency, Request currency
##### Returns
* `timestamp` - u64, Seconds since epoch when the order is created
* `expiry` - u64, Seconds after timestamp that the order expires
* `ckb_final_tlc_expiry` - u64, The minimal expiry in seconds of the final TLC in the CKB network
* `currency` - Currency, Request currency
* `wrapped_btc_type_script` - ckb_jsonrpc_types::Script, Wrapped BTC type script
* `btc_pay_req` - String, Payment request for BTC
* `ckb_pay_req` - String, Payment request for CKB
* `payment_hash` - String, Payment hash for the HTLC for both CKB and BTC.
* `amount_sats` - u128, Amount required to pay in Satoshis, including fee
* `fee_sats` - u128, Fee in Satoshis
* `status` - CchOrderStatus, Order status
#### Method `receive_btc`
Receive BTC from a payment hash.
##### Params
* `payment_hash` - String, Payment hash for the HTLC for both CKB and BTC.
* `channel_id` - Hash256, Channel ID for the CKB payment.
* `amount_sats` - u128, How many satoshis to receive, excluding cross-chain hub fee.
* `final_tlc_expiry` - u64, Expiry set for the HTLC for the CKB payment to the payee.
##### Returns
* `timestamp` - u64, Seconds since epoch when the order is created
* `expiry` - u64, Seconds after timestamp that the order expires
* `ckb_final_tlc_expiry` - u64, The minimal expiry in seconds of the final TLC in the CKB network
* `wrapped_btc_type_script` - ckb_jsonrpc_types::Script, Wrapped BTC type script
* `btc_pay_req` - String, Payment request for BTC
* `payment_hash` - String, Payment hash for the HTLC for both CKB and BTC.
* `channel_id` - Hash256, Channel ID for the CKB payment.
* `tlc_id` - `Option`, TLC ID for the CKB payment.
* `amount_sats` - u128, Amount will be received by the payee
* `fee_sats` - u128, Fee in Satoshis
* `status` - CchOrderStatus, Order status
#### Method `get_receive_btc_order`
Get receive BTC order by payment hash.
##### Params
* `payment_hash` - String, Payment hash for the HTLC for both CKB and BTC.
##### Returns
* `timestamp` - u64, Seconds since epoch when the order is created
* `expiry` - u64, Seconds after timestamp that the order expires
* `ckb_final_tlc_expiry` - u64, The minimal expiry in seconds of the final TLC in the CKB network
* `wrapped_btc_type_script` - ckb_jsonrpc_types::Script, Wrapped BTC type script
* `btc_pay_req` - String, Payment request for BTC
* `payment_hash` - String, Payment hash for the HTLC for both CKB and BTC.
* `channel_id` - Hash256, Channel ID for the CKB payment.
* `tlc_id` - `Option`, TLC ID for the CKB payment.
* `amount_sats` - u128, Amount will be received by the payee
* `fee_sats` - u128, Fee in Satoshis
* `status` - CchOrderStatus, Order status
### Module `Channel`
RPC module for channel management.
#### Method `open_channel`
Attempts to open a channel with a peer.
##### Params
* `peer_id` - PeerId, The peer ID to open a channel with.
* `funding_amount` - u128, The amount of CKB or UDT to fund the channel with.
* `public` - `Option`, Whether this is a public channel (will be broadcasted to network, and can be used to forward TLCs), an optional parameter (default value false).
* `funding_udt_type_script` - `Option