Skip to content

Commit 894eeff

Browse files
committed
fix rpc doc gen
1 parent 26da1a3 commit 894eeff

File tree

8 files changed

+61
-36
lines changed

8 files changed

+61
-36
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ members = [
88
"crates/fiber-wasm-db-common",
99
"crates/fiber-types",
1010
]
11+
exclude = ["rpc-doc-gen"]
1112
resolver = "2"
1213
default-members = ["crates/fiber-bin", "crates/fiber-lib"]
1314
[profile.release]

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ coverage-generate-report:
6767

6868
coverage: coverage-run-unittests coverage-collect-data coverage-generate-report
6969

70-
RPC_GEN_VERSION = 0.1.17
70+
RPC_GEN_VERSION = 0.1.18
7171
.PHONY: gen-rpc-doc
7272
gen-rpc-doc:
7373
@if ! command -v fiber-rpc-gen >/dev/null 2>&1 || [ "$$(fiber-rpc-gen --version | awk '{print $$2}')" != "$(RPC_GEN_VERSION)" ]; then \
7474
echo "Installing fiber-rpc-gen $(RPC_GEN_VERSION)..."; \
7575
cargo install fiber-rpc-gen --version $(RPC_GEN_VERSION) --force; \
7676
fi
77-
fiber-rpc-gen ./crates/fiber-lib/src/
77+
fiber-rpc-gen ./crates/fiber-lib/src/ --extra-types-dir ./crates/fiber-types/src/
7878
if grep -q "TODO: add desc" ./crates/fiber-lib/src/rpc/README.md; then \
7979
echo "Warning: There are 'TODO: add desc' in src/rpc/README.md, please add documentation comments to resolve them"; \
8080
exit 1; \

crates/fiber-lib/src/rpc/README.md

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ You may refer to the e2e test cases in the `tests/bruno/e2e` directory for examp
7676
* [Type `Currency`](#type-currency)
7777
* [Type `GetPaymentCommandResult`](#type-getpaymentcommandresult)
7878
* [Type `Hash256`](#type-hash256)
79+
* [Type `HashAlgorithm`](#type-hashalgorithm)
7980
* [Type `HopHint`](#type-hophint)
8081
* [Type `HopRequire`](#type-hoprequire)
8182
* [Type `Htlc`](#type-htlc)
@@ -390,7 +391,7 @@ Adds a TLC to a channel.
390391
* `amount` - <em>`u128`</em>, The amount of the TLC
391392
* `payment_hash` - <em>[Hash256](#type-hash256)</em>, The payment hash of the TLC
392393
* `expiry` - <em>`u64`</em>, The expiry of the TLC
393-
* `hash_algorithm` - <em>`Option<HashAlgorithm>`</em>, The hash algorithm of the TLC
394+
* `hash_algorithm` - <em>Option<[HashAlgorithm](#type-hashalgorithm)></em>, The hash algorithm of the TLC
394395

395396
##### Returns
396397

@@ -528,7 +529,7 @@ Get the node information.
528529
* `channel_count` - <em>`u32`</em>, The number of channels associated with the node, serialized as a hexadecimal string.
529530
* `pending_channel_count` - <em>`u32`</em>, The number of pending channels associated with the node, serialized as a hexadecimal string.
530531
* `peers_count` - <em>`u32`</em>, The number of peers connected to the node, serialized as a hexadecimal string.
531-
* `udt_cfg_infos` - <em>`UdtCfgInfos`</em>, Configuration information for User-Defined Tokens (UDT) associated with the node.
532+
* `udt_cfg_infos` - <em>[UdtCfgInfos](#type-udtcfginfos)</em>, Configuration information for User-Defined Tokens (UDT) associated with the node.
532533

533534
---
534535

@@ -556,7 +557,7 @@ Generates a new invoice.
556557
* `final_expiry_delta` - <em>`Option<u64>`</em>, The final HTLC timeout of the invoice, in milliseconds.
557558
Minimal value is 16 hours, and maximal value is 14 days.
558559
* `udt_type_script` - <em>`Option<Script>`</em>, The UDT type script of the invoice.
559-
* `hash_algorithm` - <em>`Option<HashAlgorithm>`</em>, The hash algorithm of the invoice.
560+
* `hash_algorithm` - <em>Option<[HashAlgorithm](#type-hashalgorithm)></em>, The hash algorithm of the invoice.
560561
* `allow_mpp` - <em>`Option<bool>`</em>, Whether allow payment to use MPP
561562
* `allow_trampoline_routing` - <em>`Option<bool>`</em>, Whether allow payment to use trampoline routing
562563

@@ -1089,7 +1090,7 @@ The attributes of the invoice
10891090
* `FallbackAddr` - <em>`String`</em>, The fallback address of the invoice
10901091
* `UdtScript` - <em>[CkbScript](#type-ckbscript)</em>, The udt type script of the invoice
10911092
* `PayeePublicKey` - <em>`PublicKey`</em>, The payee public key of the invoice
1092-
* `HashAlgorithm` - <em>`HashAlgorithm`</em>, The hash algorithm of the invoice
1093+
* `HashAlgorithm` - <em>[HashAlgorithm](#type-hashalgorithm)</em>, The hash algorithm of the invoice
10931094
* `Feature` - <em>`Vec<String>`</em>, The feature flags of the invoice
10941095
* `PaymentSecret` - <em>[Hash256](#type-hash256)</em>, The payment secret of the invoice
10951096
---
@@ -1302,6 +1303,18 @@ A 256-bit hash digest, used as identifier of channel, payment, transaction hash
13021303

13031304

13041305

1306+
---
1307+
1308+
<a id="#type-hashalgorithm"></a>
1309+
### Type `HashAlgorithm`
1310+
1311+
HashAlgorithm is the hash algorithm used in the hash lock.
1312+
1313+
1314+
#### Enum with values of
1315+
1316+
* `CkbHash` - The default hash algorithm, CkbHash
1317+
* `Sha256` - The sha256 hash algorithm
13051318
---
13061319

13071320
<a id="#type-hophint"></a>
@@ -1388,7 +1401,7 @@ The Node information.
13881401
When a Node is online this timestamp will be updated to the latest value.
13891402
* `chain_hash` - <em>[Hash256](#type-hash256)</em>, The chain hash of the node.
13901403
* `auto_accept_min_ckb_funding_amount` - <em>`u64`</em>, The minimum CKB funding amount for automatically accepting open channel requests.
1391-
* `udt_cfg_infos` - <em>`UdtCfgInfos`</em>, The UDT configuration infos of the node.
1404+
* `udt_cfg_infos` - <em>[UdtCfgInfos](#type-udtcfginfos)</em>, The UDT configuration infos of the node.
13921405
---
13931406

13941407
<a id="#type-paymentcustomrecords"></a>
@@ -1563,7 +1576,7 @@ Data needed to authorize and execute a Time-Locked Contract (TLC) settlement tra
15631576
#### Fields
15641577

15651578
* `tlc_id` - <em>[TLCId](#type-tlcid)</em>, The ID of the TLC (either offered or received)
1566-
* `hash_algorithm` - <em>`HashAlgorithm`</em>, The hash algorithm used for the TLC
1579+
* `hash_algorithm` - <em>[HashAlgorithm](#type-hashalgorithm)</em>, The hash algorithm used for the TLC
15671580
* `payment_amount` - <em>`u128`</em>, The amount of CKB/UDT involved in the TLC
15681581
* `payment_hash` - <em>[Hash256](#type-hash256)</em>, The hash of the payment preimage
15691582
* `expiry` - <em>`u64`</em>, The expiry time for the TLC in milliseconds
@@ -1604,9 +1617,9 @@ The UDT argument info which is used to identify the UDT configuration
16041617
#### Fields
16051618

16061619
* `name` - <em>`String`</em>, The name of the UDT.
1607-
* `script` - <em>`UdtScript`</em>, The script of the UDT.
1620+
* `script` - <em>[UdtScript](#type-udtscript)</em>, The script of the UDT.
16081621
* `auto_accept_amount` - <em>`Option<u128>`</em>, The minimum amount of the UDT that can be automatically accepted.
1609-
* `cell_deps` - <em>`Vec<UdtDep>`</em>, The cell deps of the UDT.
1622+
* `cell_deps` - <em>Vec<[UdtDep](#type-udtdep)></em>, The cell deps of the UDT.
16101623
---
16111624

16121625
<a id="#type-udtcelldep"></a>
@@ -1638,7 +1651,7 @@ Udt script on-chain dependencies.
16381651

16391652
#### Fields
16401653

1641-
* `cell_dep` - <em>`Option<UdtCellDep>`</em>, cell dep described by out_point.
1654+
* `cell_dep` - <em>Option<[UdtCellDep](#type-udtcelldep)></em>, cell dep described by out_point.
16421655
* `type_id` - <em>`Option<Script>`</em>, cell dep described by type ID.
16431656
---
16441657

crates/fiber-types/src/cch.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ use lightning_invoice::Bolt11Invoice;
88
use serde::{Deserialize, Serialize};
99
use serde_with::{serde_as, DisplayFromStr};
1010

11-
/// The status of a cross-chain hub order.
11+
/// The status of a cross-chain hub order, will update as the order progresses.
1212
#[derive(Debug, Copy, Clone, Serialize, Deserialize, Eq, PartialEq)]
1313
#[serde(rename_all = "snake_case")]
1414
pub enum CchOrderStatus {
1515
/// Order is created and waiting for the incoming invoice to collect enough TLCs.
1616
Pending = 0,
17-
/// The incoming invoice collected the required TLCs.
17+
/// The incoming invoice collected the required TLCs and is ready to send outgoing payment to obtain the preimage.
1818
IncomingAccepted = 1,
1919
/// The outgoing payment is in flight.
2020
OutgoingInFlight = 2,

crates/fiber-types/src/channel.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ bitflags! {
103103
// TLC types
104104
// ============================================================
105105

106-
/// The id of a TLC, it can be either offered or received.
106+
/// The id of a tlc, it can be either offered or received.
107107
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, PartialOrd, Ord, Hash)]
108108
pub enum TLCId {
109-
/// Offered TLC id
109+
/// Offered tlc id
110110
Offered(u64),
111-
/// Received TLC id
111+
/// Received tlc id
112112
Received(u64),
113113
}
114114

@@ -178,12 +178,12 @@ pub enum InboundTlcStatus {
178178
RemoveAckConfirmed,
179179
}
180180

181-
/// The status of a TLC
181+
/// The status of a tlc
182182
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]
183183
pub enum TlcStatus {
184-
/// Outbound TLC
184+
/// Outbound tlc
185185
Outbound(OutboundTlcStatus),
186-
/// Inbound TLC
186+
/// Inbound tlc
187187
Inbound(InboundTlcStatus),
188188
}
189189

crates/fiber-types/src/invoice.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ pub fn parse_hrp(input: &str) -> Result<(Currency, Option<u128>), InvoiceError>
217217
// Invoice status
218218
// ============================================================
219219

220-
/// The status of a CKB invoice.
220+
/// The currency of the invoice, can also used to represent the CKB network chain.
221221
#[derive(Debug, Clone, Copy, Eq, PartialEq, Serialize, Deserialize)]
222222
pub enum CkbInvoiceStatus {
223223
/// The invoice is open and can be paid.
@@ -248,7 +248,7 @@ impl Display for CkbInvoiceStatus {
248248
// Currency
249249
// ============================================================
250250

251-
/// The currency of the invoice, can also represent the CKB network chain.
251+
/// The currency of the invoice, can also used to represent the CKB network chain.
252252
#[derive(Debug, Clone, Copy, Eq, PartialEq, Serialize, Deserialize, Default)]
253253
pub enum Currency {
254254
/// The mainnet currency of CKB.
@@ -374,7 +374,7 @@ pub struct CkbScript(#[serde_as(as = "EntityHex")] pub PackedScript);
374374
// InvoiceSignature
375375
// ============================================================
376376

377-
/// Recoverable signature for an invoice.
377+
/// Recoverable signature
378378
#[derive(Clone, Debug, Eq, PartialEq)]
379379
pub struct InvoiceSignature(pub RecoverableSignature);
380380

crates/fiber-types/src/payment.rs

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,23 @@ use strum::{AsRefStr, EnumString};
1414
// Payment status
1515
// ============================================================
1616

17-
/// The status of a payment.
17+
/// The status of a payment, will update as the payment progresses.
18+
/// The transfer path for payment status is `Created -> Inflight -> Success | Failed`.
19+
///
20+
/// **MPP Behavior**: A single session may involve multiple attempts (HTLCs) to fulfill the total amount.
1821
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
1922
pub enum PaymentStatus {
23+
/// Initial status. A payment session is created, but no HTLC has been dispatched.
2024
Created,
25+
/// The first hop AddTlc is sent successfully and waiting for the response.
26+
///
27+
/// > **MPP Logic**: Status `Inflight` means at least one attempt is still not in `Success`, payment needs more retrying or waiting for HTLC settlement.
2128
Inflight,
29+
/// The payment is finished. All related HTLCs are successfully settled,
30+
/// and the aggregate amount equals the total requested amount.
2231
Success,
32+
/// The payment session has terminated. HTLCs have failed and the target
33+
/// amount cannot be fulfilled after exhausting all retries.
2334
Failed,
2435
}
2536

@@ -1022,16 +1033,16 @@ pub struct RemoveTlcFulfill {
10221033

10231034
use crate::U128Hex;
10241035

1025-
/// The node and channel information in a payment route hop.
1036+
/// The node and channel information in a payment route hop
10261037
#[serde_as]
10271038
#[derive(Clone, Debug, Serialize, Deserialize)]
10281039
pub struct SessionRouteNode {
1029-
/// The public key of the node.
1040+
/// the public key of the node
10301041
pub pubkey: Pubkey,
1031-
/// The amount for this hop.
1042+
/// the amount for this hop
10321043
#[serde_as(as = "U128Hex")]
10331044
pub amount: u128,
1034-
/// The channel outpoint for this hop.
1045+
/// the channel outpoint for this hop
10351046
#[serde_as(as = "EntityHex")]
10361047
pub channel_outpoint: OutPoint,
10371048
}
@@ -1042,16 +1053,15 @@ pub struct SessionRouteNode {
10421053

10431054
use crate::U64Hex;
10441055

1045-
/// A router hop information for a payment.
1046-
/// A payment router is an array of RouterHop.
1047-
/// A router hop generally implies hop `target` will receive `amount_received` with `channel_outpoint` of channel.
1048-
/// Improper hop hint may make payment fail, for example the specified channel does not have enough capacity.
1056+
/// A router hop information for a payment, a paymenter router is an array of RouterHop,
1057+
/// a router hop generally implies hop `target` will receive `amount_received` with `channel_outpoint` of channel.
1058+
/// Improper hop hint may make payment fail, for example the specified channel do not have enough capacity.
10491059
#[serde_as]
10501060
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
10511061
pub struct RouterHop {
10521062
/// The node that is sending the TLC to the next node.
10531063
pub target: Pubkey,
1054-
/// The channel of this hop used to receive TLC.
1064+
/// The channel of this hop used to receive TLC
10551065
#[serde_as(as = "EntityHex")]
10561066
pub channel_outpoint: OutPoint,
10571067
/// The amount that the source node will transfer to the target node.
@@ -1166,12 +1176,13 @@ impl From<molecule_fiber::RemoveTlcReason> for RemoveTlcReason {
11661176

11671177
/// The router is a list of nodes that the payment will go through.
11681178
/// We store in the payment session and then will use it to track the payment history.
1179+
/// The router is a list of nodes that the payment will go through.
11691180
/// For example:
11701181
/// `A(amount, channel) -> B -> C -> D`
11711182
/// means A will send `amount` with `channel` to B.
11721183
#[derive(Clone, Debug, Serialize, Deserialize, Default)]
11731184
pub struct SessionRoute {
1174-
/// The nodes in the route.
1185+
/// the nodes in the route
11751186
pub nodes: Vec<SessionRouteNode>,
11761187
}
11771188

crates/fiber-types/src/primitives.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ impl From<bitcoin::hashes::sha256::Hash> for Hash256 {
158158

159159
const PUBKEY_SIZE: usize = 33;
160160

161-
/// The public key for a Node.
162-
/// It stores the serialized form ([u8; 33]) directly for fast comparison and hashing.
161+
/// The public key for a Node
162+
/// It stores the serialized form ([u8; 33]) directly for fast comparison and hashing
163163
#[serde_as]
164164
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Hash, Serialize, Deserialize)]
165165
pub struct Pubkey(#[serde_as(as = "IfIsHumanReadable<SliceHexNoPrefix, [_; 33]>")] pub [u8; 33]);
@@ -313,7 +313,7 @@ impl TryFrom<molecule_fiber::Pubkey> for Pubkey {
313313
// Privkey
314314
// ============================================================
315315

316-
/// A wrapper for secp256k1 secret key.
316+
/// A wrapper for secp256k1 secret key
317317
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
318318
pub struct Privkey(pub secp256k1::SecretKey);
319319

0 commit comments

Comments
 (0)