From 72f5cc24754f9ab68c0204af567450fbc0dde620 Mon Sep 17 00:00:00 2001 From: Evan Kaloudis Date: Fri, 17 Jan 2025 11:43:08 -0500 Subject: [PATCH] LSPS7: Create order: add block heights --- locales/en.json | 2 +- views/Channels/Channel.tsx | 10 ++++-- views/LSPS7/OrderResponse.tsx | 2 +- views/LSPS7/index.tsx | 57 ++++++++++++++++++++++++++++++++--- 4 files changed, 63 insertions(+), 8 deletions(-) diff --git a/locales/en.json b/locales/en.json index aba6c0708e..755c551cbb 100644 --- a/locales/en.json +++ b/locales/en.json @@ -1093,9 +1093,9 @@ "views.LSPS7.type": "Channel lease extension", "views.LSPS7.channelExtensionBlocks": "Number of blocks to extend channel lease by", "views.LSPS7.extensionExpiryBlocks": "Extension expiry blocks", - "views.LSPS7.newChannelExpiryBlock": "New channel expiry block", "views.LSPS7.maxChannelExtensionExpiryBlocks": "Max channel extension expiry blocks", "views.LSPS7.expirationBlock": "Current expiration block", + "views.LSPS7.proposedExpirationBlock": "Proposed expiration block", "views.LSPS7.originalOrderId": "Original order ID", "views.LSPS7.originalService": "Original service", "views.LSPS7.extensionOrderIds": "Extension Order IDs", diff --git a/views/Channels/Channel.tsx b/views/Channels/Channel.tsx index fab252d598..f6ad2748e5 100644 --- a/views/Channels/Channel.tsx +++ b/views/Channels/Channel.tsx @@ -83,6 +83,7 @@ interface ChannelState { expiresMonths?: number; expiresDays?: number; maxExtensionInBlocks?: number; + expirationBlock?: number; }; } @@ -137,6 +138,8 @@ export default class ChannelView extends React.Component< renewalInfo.max_channel_extension_expiry_blocks; } + const expirationBlock = renewalInfo?.expiration_block; + this.state = { confirmCloseChannel: false, satPerByte: '', @@ -148,7 +151,8 @@ export default class ChannelView extends React.Component< expiresInBlocks, expiresDays, expiresMonths, - maxExtensionInBlocks + maxExtensionInBlocks, + expirationBlock } }; @@ -595,7 +599,9 @@ export default class ChannelView extends React.Component< navigation.navigate('LSPS7', { chanId: shortChannelId, maxExtensionInBlocks: - renewalInfo.maxExtensionInBlocks + renewalInfo.maxExtensionInBlocks, + expirationBlock: + renewalInfo.expirationBlock }); }} ViewComponent={LinearGradient} diff --git a/views/LSPS7/OrderResponse.tsx b/views/LSPS7/OrderResponse.tsx index f17d910aa0..f95aab9b2b 100644 --- a/views/LSPS7/OrderResponse.tsx +++ b/views/LSPS7/OrderResponse.tsx @@ -59,7 +59,7 @@ export default class LSPS7OrderResponse extends React.Component< {orderResponse?.new_channel_expiry_block && ( ; } @@ -62,6 +63,7 @@ interface LSPS7State { advancedSettings: boolean; chanId: string; maxExtensionInBlocks: number; + expirationBlock: number; } @inject( @@ -79,6 +81,7 @@ export default class LSPS7 extends React.Component { const chanId = props?.route.params?.chanId; const maxExtensionInBlocks = props?.route.params?.maxExtensionInBlocks; + const expirationBlock = props?.route.params?.expirationBlock; let expirationIndex = 4; if (maxExtensionInBlocks === 4380) { @@ -99,7 +102,8 @@ export default class LSPS7 extends React.Component { showInfo: false, advancedSettings: false, chanId, - maxExtensionInBlocks + maxExtensionInBlocks, + expirationBlock }; } @@ -144,16 +148,19 @@ export default class LSPS7 extends React.Component { }; render() { - const { navigation, LSPStore, InvoicesStore } = this.props; + const { navigation, LSPStore, NodeInfoStore, InvoicesStore } = + this.props; const { showInfo, advancedSettings, channelExtensionBlocks, expirationIndex, chanId, - maxExtensionInBlocks + maxExtensionInBlocks, + expirationBlock } = this.state; const { createExtensionOrderResponse } = LSPStore; + const { nodeInfo } = NodeInfoStore; const result = createExtensionOrderResponse?.result || createExtensionOrderResponse; @@ -270,6 +277,16 @@ export default class LSPS7 extends React.Component { ? 'Olympus by ZEUS' : LSPStore.getLSPSPubkey(); + const proposedNewExpirationBlock = numberWithCommas( + new BigNumber( + new BigNumber(nodeInfo.currentBlockHeight).gt(expirationBlock) + ? nodeInfo.currentBlockHeight + : expirationBlock + ) + .plus(channelExtensionBlocks) + .toNumber() + ); + return (
{ )} value={chanId} /> + + + + + + <> @@ -703,7 +752,7 @@ export default class LSPS7 extends React.Component { }; orderData.clientPubkey = - this.props.NodeInfoStore.nodeInfo.nodeId; + nodeInfo?.nodeId; orderData.peer = LSPStore.getLSPSPubkey(); orderData.uri = `${LSPStore.getLSPSPubkey()}@${LSPStore.getLSPS1Host()}`;