Skip to content

Conversation

@jamaljsr
Copy link
Collaborator

@jamaljsr jamaljsr commented Mar 9, 2019

Closes #181

Description

Adds a new field to the Open Channel form giving the option to choose the transaction speed. This will set the sats/byte to a predetermined value based on the current BTC mainnet mempool.

Note: Fee estimates are only provided for BTC so this field is hidden when connected to an LTC node

Steps to Test

  1. Click on Open channel from the top right nav menu
  2. Click on the Show advanced fields button in the modal
  3. Choose a fee level (auto/slow/normal/fast)
  4. Confirm the sats/byte changes in the help message below the toggle
  5. Click the Open Channel button to send the transaction
  6. View the transaction in a block explorer to verify that your fee was used. You can open two channels to to confirm that choosing the Fast option is cheaper than Auto

Screenshots

@jamaljsr
Copy link
Collaborator Author

I added the ability to manually specify a custom fee (sats/byte) in the fee selection field. It also displays a warning if the specified fee is larger than the fastest recommended fee.

@jamaljsr
Copy link
Collaborator Author

I just committed an alternative UI using a slider instead of the toggle/input combo. I think this may be a better solution as it reduces the chances of someone fat-fingering a really high fee unnecessarily. It also greatly simplifies the error detection code.

If you prefer the previous UI, then I can easily revert the last commit. I just wanted to throw this out there as I felt it is a better approach.

@wbobeirne
Copy link
Member

Love the new UI. Will be taking a look at this a little later, but definitely prefer this direction!

Copy link
Member

@wbobeirne wbobeirne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just worried about the chainsend comment, if that's all good then I'm 100% 👍 on this one. Great work!

capacity,
isPrivate,
// only send non-zero fee
fee: fee ? fee.toString() : undefined,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does handleFeeSubmit in ChainSend need the same consideration here? Looks like it could send 0 right now.

switch (v) {
case onChainFees.fastestFee: return 'fastest';
case onChainFees.halfHourFee: return 'normal';
case onChainFees.hourFee: return 'slow';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice if these kept the number as well, e.g. 16 (normal)

@jamaljsr
Copy link
Collaborator Author

Great feedback. Thanks for the review. I’ll get these couple items fixed up as soon as I can.

this.props.getOnChainFeeEstimates();
}

componentWillReceiveProps(nextProps: Props) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI componentWillReceiveProps will be deprecated in React 17 and generally a good upgrade path for this kind of function is to use componentDidUpdate instead and compare against prevProps instead of nextProps

https://reactjs.org/docs/react-component.html#updating

More of a long term consideration but noticed it because I write a ton of React and have gotten used to it by now

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh React, always deprecating lifecycles... Thanks for the heads up! We can probably let this one slip since we're using this lifecycle in quite a few places, and can just do one big refactor when we come around to v17.

const { onChainFees } = this.props;
if (nextProps.onChainFees !== onChainFees && nextProps.onChainFees !== null) {
const { fastestFee } = nextProps.onChainFees;
this.setState({ fee: fastestFee });
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also just took a look at the parent component and am wondering whether you wouldn’t need local state in this component and you can just pass the fee as a prop from the ChainSend component since it seems like you’re managing changes to both this local state and the parents local state?

All good if you have your reasoning that I don’t see, but in any case these are just architecture suggestions and not functionally critical.

Love the slider UI btw 👍👍👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this idea, making it a controlled component rather than an uncontrolled one. Better matches the paradigm of most input components we have.

Copy link
Member

@wbobeirne wbobeirne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jamaljsr I've got some free time today so I'm going to tackle the PR feedback here. I'll push the changes up and wait for you to 👍 before merging in.

const { onChainFees } = this.props;
if (nextProps.onChainFees !== onChainFees && nextProps.onChainFees !== null) {
const { fastestFee } = nextProps.onChainFees;
this.setState({ fee: fastestFee });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this idea, making it a controlled component rather than an uncontrolled one. Better matches the paradigm of most input components we have.

this.props.getOnChainFeeEstimates();
}

componentWillReceiveProps(nextProps: Props) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh React, always deprecating lifecycles... Thanks for the heads up! We can probably let this one slip since we're using this lifecycle in quite a few places, and can just do one big refactor when we come around to v17.

@jamaljsr
Copy link
Collaborator Author

jamaljsr commented Mar 20, 2019

hey @wbobeirne I am traveling and wont be able to make any changes to this branch until this weekend. Feel free to make any additional updates you think are improvements.

Great feedback @otech47, thank you very much.

    * Make FeeSelectField a controlled component
    * Show number when hovered over labeled fee estimates
    * Fix ChainSend automatic fee calculation
@wbobeirne
Copy link
Member

No worries, hope it's somewhere sunny. I just pushed changes to address the feedback, and merged develop back in to fix the snyk CI. If you don't get a chance to review, I'll probably merge as is since I tested it pretty thoroughly and it all LGTM.

@wbobeirne wbobeirne merged commit a6d756a into joule-labs:develop Mar 21, 2019
@jamaljsr jamaljsr deleted the feat/open-channel-fee branch March 22, 2019 12:08
@jamaljsr
Copy link
Collaborator Author

@wbobeirne Thanks for cleaning this up and getting it merged 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants