-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fund channel flow #2544
Fund channel flow #2544
Conversation
92ccceb
to
33202e7
Compare
This comment was marked as outdated.
This comment was marked as outdated.
We know if finished syncing because `syncing` is `false` and the screen will finish reloading.
c2c1b98
to
4868b9d
Compare
Final version before review :) Simulator.Screen.Recording.-.iPhone.15.Plus.-.2024-05-20.at.16.25.03.mp4 |
Column buildInfoBox(FundingChannelTaskStatus? value, FundinType selectedBox) { | ||
String transactionStatusText = "Waiting for payment..."; | ||
String transactionStatusInformationText = | ||
"Please wait. If you leave now, your position won’t be opened when the funds arrive."; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 if the user would want to switch to another app to send the onchain funds this message might be misleading.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be. Do you have a proposal to change this?
❓ It's a bit weird to me that one jumps from the modal to a screen. What do you think about showing the new screens also as modals? |
❓ Did you test this with smaller devices? |
❓ Do we still need to show the QR code when the trade is executing? I think I would prefer if the user sees directly the position tab. |
mobile/lib/features/trade/channel_creation_flow/channel_configuration_screen.dart
Outdated
Show resolved
Hide resolved
mobile/lib/features/trade/channel_creation_flow/channel_configuration_screen.dart
Show resolved
Hide resolved
children: [ | ||
TextSpan( | ||
text: | ||
"🔔 This is your first trade and you do not have a channel yet. " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the video this is very hard to read. I also think its too much text, maybe the title is enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to propose something else :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe the title is enough?
😅
value: ownTotalCollateral, | ||
label: 'Channel size'), | ||
FeeExpansionTile( | ||
label: "Fee*", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔧 The asterix isn't pointing to anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair, I wanted to indicate that one can click on it.
I agree, I switched to an extra screen because the modals were a pita to design. |
Yes, tested iPhone SE and looks ok. |
Probably not. I think there is lots we could improve. For example, I wouldn't show the popup dialog here at all but it's kinda impossible to control 😬 |
6bbb5c0
to
5143cd9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I did not delve into the Flutter code, but the screens look like a good starting point!
crates/xxi-node/src/node/mod.rs
Outdated
tracing::error!( | ||
txid = tx.txid.to_string(), | ||
address = address.to_string(), | ||
"Output not found. This should not happen, but if, it indicates something is wrong."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Output not found. This should not happen, but if, it indicates something is wrong."); | |
"Output not found. This should not happen, but if it does, it indicates something is wrong."); |
@@ -125,6 +129,7 @@ impl Subscriber for FlutterSubscriber { | |||
EventType::ServiceHealthUpdate, | |||
EventType::ChannelStatusUpdate, | |||
EventType::BackgroundNotification, | |||
EventType::FundingChannelNotification, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only spent 1 hour yesterday debugging because I forgot to add my new EventType
❤️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to hear ... this literally happened to me as well :/
mobile/native/src/lib.rs
Outdated
@@ -36,3 +36,4 @@ pub use report_error::report_error_to_coordinator; | |||
)] | |||
mod bridge_generated; | |||
mod position; | |||
pub mod unfunded_orders; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙃 Should go with the other pub mod
s in this file.
mobile/native/src/max_quantity.rs
Outdated
@@ -126,7 +139,7 @@ pub fn max_quantity( | |||
Ok(max_quantity) | |||
} | |||
|
|||
/// Calculates the max quantity for the given input parameters. If an on-chai fee estimate is | |||
/// Calculates the max quantity. If an on-chai fee estimate is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Calculates the max quantity. If an on-chai fee estimate is | |
/// Calculates the max quantity. If an on-chain fee estimate is |
mobile/native/src/unfunded_orders.rs
Outdated
use std::time::Duration; | ||
use xxi_node::commons::ChannelOpeningParams; | ||
|
||
pub(crate) async fn submit_unfunded_channel_opening_order( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙃 Every channel that is not yet open is unfunded. We could go for submit_unfunded_wallet_channel_opening_order
or submit_channel_opening_order_without_utxos
.
mobile/native/src/unfunded_orders.rs
Outdated
event::publish(&EventInternal::FundingChannelNotification( | ||
FundingChannelTask::Pending, | ||
)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ Why do you need to send Pending
so many times?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good question 🙈
if let Err(error) = bdk_node.sync_on_chain_wallet().await { | ||
tracing::error!("Failed at syncing wallet {error:?}") | ||
} | ||
|
||
let balance = bdk_node.get_on_chain_balance(); | ||
tracing::debug!(balance = balance.to_string(), "Wallet synced"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔧 The second log message can contradict the first one.
Should we just loop until the on-chain balance is enough? We confirmed that the UTXOs are there, but we can also confirm that the balance is up to date.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, we could try to do it without the manual sync. It might not be necessary if we have broken out of the loop above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured syncing the wallet is more expensive than looking up just a single address. But you are right, this would be an alternative.
Alternatively, we could try to do it without the manual sync. It might not be necessary if we have broken out of the loop above.
Unfortunately we need to sync the wallet once we found the address holds enough funds as otherwise we might fail later on because the wallet thinks it doesn't have enough funds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured syncing the wallet is more expensive than looking up just a single address. But you are right, this would be an alternative.
Right. My first suggestion was to sync in a loop after the first loop has exited successfully. In theory, you only need to sync once, but there is an error path that we are currently just logging. I think if we fail to sync we want to keep trying until the UTXOs that we think should be there appear in the wallet.
Unfortunately we need to sync the wallet once we found the address holds enough funds as otherwise we might fail later on because the wallet thinks it doesn't have enough funds.
Okay, so one successful sync is necessary.
mobile/native/src/unfunded_orders.rs
Outdated
} | ||
.remote_handle(); | ||
|
||
// We need to store the handler which will drop any old handler if present. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// We need to store the handler which will drop any old handler if present. | |
// We need to store the handle which will drop any old handle if present. |
We introduce a new flow to fund the first position and with it the first channel. The idea is that the user does not have to have any on-chain funds before opening the first position. The flow is divided into two parts: 1) open a position using on-chain funds: if the user has already on-chain funds, then he can opt to use said funds and open the channel immediately 2) open a position using external funds: the user has the option to fund the wallet using an external wallet such as a lightning wallet, another on-chain wallet, or maybe even using a hardware wallet in the future. In this patch, we only introduce funding using an on-chain transaction. The app waits until it sees the funds incoming and then proceeds with the channel creation.
We can't navigate using the mocked router (I don't understand why). Which means, we can't navigate to the new channel configuration flow. Because of this, I've split up the tests into more fine granular tests. We test now each widget separately. This has the advantage that our tests are smaller and easier to understand. It seems like that if we want to test navigation, we should write integration tests instead.
5143cd9
to
ef42084
Compare
Ready for review :)