Skip to content

Commit

Permalink
Merge pull request #53 from kumulynja/payment-timestamp
Browse files Browse the repository at this point in the history
add latestUpdateTimestamp to PaymentDetails
  • Loading branch information
BitcoinZavior authored Jul 18, 2024
2 parents a63db29 + 38c89a0 commit 3dce03d
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 2,252 deletions.
1 change: 1 addition & 0 deletions ios/Classes/frb_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ typedef struct wire_cst_payment_details {
uint64_t *amount_msat;
int32_t direction;
int32_t status;
uint64_t latest_update_timestamp;
} wire_cst_payment_details;

typedef struct wire_cst_channel_details {
Expand Down
10 changes: 8 additions & 2 deletions lib/src/generated/api/types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1259,12 +1259,16 @@ class PaymentDetails {
/// The status of the payment.
final PaymentStatus status;

/// The timestamp, in seconds since start of the UNIX epoch, when this entry was last updated.
final BigInt latestUpdateTimestamp;

const PaymentDetails({
required this.id,
required this.kind,
this.amountMsat,
required this.direction,
required this.status,
required this.latestUpdateTimestamp,
});

@override
Expand All @@ -1273,7 +1277,8 @@ class PaymentDetails {
kind.hashCode ^
amountMsat.hashCode ^
direction.hashCode ^
status.hashCode;
status.hashCode ^
latestUpdateTimestamp.hashCode;

@override
bool operator ==(Object other) =>
Expand All @@ -1284,7 +1289,8 @@ class PaymentDetails {
kind == other.kind &&
amountMsat == other.amountMsat &&
direction == other.direction &&
status == other.status;
status == other.status &&
latestUpdateTimestamp == other.latestUpdateTimestamp;
}

/// Represents the direction of a payment.
Expand Down
10 changes: 7 additions & 3 deletions lib/src/generated/frb_generated.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3693,14 +3693,15 @@ class coreApiImpl extends coreApiImplPlatform implements coreApi {
PaymentDetails dco_decode_payment_details(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
final arr = raw as List<dynamic>;
if (arr.length != 5)
throw Exception('unexpected arr length: expect 5 but see ${arr.length}');
if (arr.length != 6)
throw Exception('unexpected arr length: expect 6 but see ${arr.length}');
return PaymentDetails(
id: dco_decode_payment_id(arr[0]),
kind: dco_decode_payment_kind(arr[1]),
amountMsat: dco_decode_opt_box_autoadd_u_64(arr[2]),
direction: dco_decode_payment_direction(arr[3]),
status: dco_decode_payment_status(arr[4]),
latestUpdateTimestamp: dco_decode_u_64(arr[5]),
);
}

Expand Down Expand Up @@ -5733,12 +5734,14 @@ class coreApiImpl extends coreApiImplPlatform implements coreApi {
var var_amountMsat = sse_decode_opt_box_autoadd_u_64(deserializer);
var var_direction = sse_decode_payment_direction(deserializer);
var var_status = sse_decode_payment_status(deserializer);
var var_latestUpdateTimestamp = sse_decode_u_64(deserializer);
return PaymentDetails(
id: var_id,
kind: var_kind,
amountMsat: var_amountMsat,
direction: var_direction,
status: var_status);
status: var_status,
latestUpdateTimestamp: var_latestUpdateTimestamp);
}

@protected
Expand Down Expand Up @@ -7745,6 +7748,7 @@ class coreApiImpl extends coreApiImplPlatform implements coreApi {
sse_encode_opt_box_autoadd_u_64(self.amountMsat, serializer);
sse_encode_payment_direction(self.direction, serializer);
sse_encode_payment_status(self.status, serializer);
sse_encode_u_64(self.latestUpdateTimestamp, serializer);
}

@protected
Expand Down
5 changes: 5 additions & 0 deletions lib/src/generated/frb_generated.io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3139,6 +3139,8 @@ abstract class coreApiImplPlatform extends BaseApiImpl<coreWire> {
wireObj.amount_msat = cst_encode_opt_box_autoadd_u_64(apiObj.amountMsat);
wireObj.direction = cst_encode_payment_direction(apiObj.direction);
wireObj.status = cst_encode_payment_status(apiObj.status);
wireObj.latest_update_timestamp =
cst_encode_u_64(apiObj.latestUpdateTimestamp);
}

@protected
Expand Down Expand Up @@ -7268,6 +7270,9 @@ final class wire_cst_payment_details extends ffi.Struct {

@ffi.Int32()
external int status;

@ffi.Uint64()
external int latest_update_timestamp;
}

final class wire_cst_channel_details extends ffi.Struct {
Expand Down
3 changes: 3 additions & 0 deletions rust/src/api/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,8 @@ pub struct PaymentDetails {
pub direction: PaymentDirection,
/// The status of the payment.
pub status: PaymentStatus,
/// The timestamp, in seconds since start of the UNIX epoch, when this entry was last updated.
pub latest_update_timestamp: u64,
}

impl From<ldk_node::payment::PaymentDetails> for PaymentDetails {
Expand All @@ -759,6 +761,7 @@ impl From<ldk_node::payment::PaymentDetails> for PaymentDetails {
amount_msat: value.amount_msat,
direction: value.direction.into(),
kind: value.kind.into(),
latest_update_timestamp: value.latest_update_timestamp,
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions rust/src/frb_generated.io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,7 @@ impl CstDecode<crate::api::types::PaymentDetails> for wire_cst_payment_details {
amount_msat: self.amount_msat.cst_decode(),
direction: self.direction.cst_decode(),
status: self.status.cst_decode(),
latest_update_timestamp: self.latest_update_timestamp.cst_decode(),
}
}
}
Expand Down Expand Up @@ -1991,6 +1992,7 @@ impl NewWithNullPtr for wire_cst_payment_details {
amount_msat: core::ptr::null_mut(),
direction: Default::default(),
status: Default::default(),
latest_update_timestamp: Default::default(),
}
}
}
Expand Down Expand Up @@ -4072,6 +4074,7 @@ pub struct wire_cst_payment_details {
amount_msat: *mut u64,
direction: i32,
status: i32,
latest_update_timestamp: u64,
}
#[repr(C)]
#[derive(Clone, Copy)]
Expand Down
4 changes: 4 additions & 0 deletions rust/src/frb_generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3498,12 +3498,14 @@ impl SseDecode for crate::api::types::PaymentDetails {
let mut var_amountMsat = <Option<u64>>::sse_decode(deserializer);
let mut var_direction = <crate::api::types::PaymentDirection>::sse_decode(deserializer);
let mut var_status = <crate::api::types::PaymentStatus>::sse_decode(deserializer);
let mut var_latestUpdateTimestamp = <u64>::sse_decode(deserializer);
return crate::api::types::PaymentDetails {
id: var_id,
kind: var_kind,
amount_msat: var_amountMsat,
direction: var_direction,
status: var_status,
latest_update_timestamp: var_latestUpdateTimestamp,
};
}
}
Expand Down Expand Up @@ -5154,6 +5156,7 @@ impl flutter_rust_bridge::IntoDart for crate::api::types::PaymentDetails {
self.amount_msat.into_into_dart().into_dart(),
self.direction.into_into_dart().into_dart(),
self.status.into_into_dart().into_dart(),
self.latest_update_timestamp.into_into_dart().into_dart(),
]
.into_dart()
}
Expand Down Expand Up @@ -6971,6 +6974,7 @@ impl SseEncode for crate::api::types::PaymentDetails {
<Option<u64>>::sse_encode(self.amount_msat, serializer);
<crate::api::types::PaymentDirection>::sse_encode(self.direction, serializer);
<crate::api::types::PaymentStatus>::sse_encode(self.status, serializer);
<u64>::sse_encode(self.latest_update_timestamp, serializer);
}
}

Expand Down
Loading

0 comments on commit 3dce03d

Please sign in to comment.