Skip to content
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

fix: rpc send transfer recipient choose fee #5238

Merged
merged 1 commit into from
Apr 16, 2024

Conversation

alter-eggo
Copy link
Contributor

@alter-eggo alter-eggo commented Apr 16, 2024

Try out Leather build a739014Extension build, Test report, Storybook, Chromatic

This pr fixes bug with rpc send transfer fees selection. Here I just duplicated components in order not to affect other flows. In next pr I will refactor it

@kyranjamie
Copy link
Collaborator

Thanks @alter-eggo, think we should include in this PR:

  • Fixing the styling on the confirmation page, it's not centred properly
  • Adding validation if network & network of addresses provided don't match
  • Adding validation if decimal amount provided, and we expect sat denominated amounts only

(value, context) => {
const contextOptions = context.options as any;
const network = contextOptions.from[1].value.network as BitcoinNetworkModes;
return btcAddressNetworkValidator(network).isValidSync(value);
Copy link
Collaborator

Choose a reason for hiding this comment

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

magic number, what's 1?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

seems, there is no other ways to get network here

{} as Record<AddressType, number>
);

const outputsData = (Object.keys(outputTypesLengthMap) as AddressType[]).map(v => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

what is v? please name fully

Copy link
Contributor Author

Choose a reason for hiding this comment

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

renamed to outputAddressType

(acc: Record<AddressType, number>, outputType) => {
// we add 1 output for change address if not sending max
if (!acc['p2wpkh'] && !isSendMax) {
acc['p2wpkh'] = 1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

what is 1?

Copy link
Contributor Author

@alter-eggo alter-eggo Apr 16, 2024

Choose a reason for hiding this comment

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

default output length value

// Fee has already been deducted from the amount with send all
const outputs = recipients.map(({ address, amount }) => ({ value: BigInt(amount), address }));

const fee = Math.ceil(sizeInfo.txVBytes * feeRate);
Copy link
Collaborator

Choose a reason for hiding this comment

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

use BigNumber for math

Copy link
Contributor Author

Choose a reason for hiding this comment

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

most of this fn is copy-pasted, I can refactor math there later?

Copy link
Collaborator

@kyranjamie kyranjamie left a comment

Choose a reason for hiding this comment

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

Thanks @alter-eggo. Let's follow up with tests and refactor as soon as this is shipped!

@alter-eggo alter-eggo added this pull request to the merge queue Apr 16, 2024
Merged via the queue into dev with commit 1a5fb85 Apr 16, 2024
28 checks passed
@alter-eggo alter-eggo deleted the fix/send-transfer-recipient branch April 16, 2024 15:46
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.

2 participants