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

zec: implement zip 317 #2338

Closed
wants to merge 2 commits into from
Closed

zec: implement zip 317 #2338

wants to merge 2 commits into from

Conversation

buck54321
Copy link
Member

@buck54321 buck54321 commented May 3, 2023

Adds support for ZIP-0317 fee calculations, though we've always done fees for Zcash wrong. Previously, fee should have been 1000 zats per tx, regardless of size. Now, fees are 5000 zats per "logical action".

Making these calculations possible required a pretty deep integration. I've tried to do so in a way that makes this easy to review. This has been roughly tested manually.

@buck54321 buck54321 marked this pull request as draft May 3, 2023 17:22
@buck54321 buck54321 changed the title implement zip 317 zec: implement zip 317 May 3, 2023
@buck54321 buck54321 force-pushed the zec-fees branch 2 times, most recently from 5385420 to eb2af19 Compare May 3, 2023 21:29
Copy link
Collaborator

@martonp martonp left a comment

Choose a reason for hiding this comment

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

It's looking good to me. Still need to test though.

@@ -26,6 +26,9 @@ type Tx struct {
// Used to conditionally skip block lookups on mempool transactions during
// calls to Confirmations.
lastLookup *chainhash.Hash
// fees is the fees paid in the tx. fees is used Zcash. It is exposed by the
Copy link
Collaborator

Choose a reason for hiding this comment

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

*fees is used by Zcash

// Satisfies the asset.OrderEstimator interface.
func (be *ZECBackend) CalcOrderFunds(swapVal, inputCount, inputsSize, maxSwaps uint64) uint64 {
return dexzec.RequiredOrderFunds(swapVal, inputCount, inputsSize, maxSwaps)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

var _ asset.OrderEstimator = (*ZECBackend)(nil)

@@ -0,0 +1,20 @@
\documentclass[]{article}
Copy link
Member

@chappjc chappjc May 4, 2023

Choose a reason for hiding this comment

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

Why don't we just link to the ZIP 317 page? I don't think we need to check in a 120 KB png file either.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ooooh. I was reading at https://github.com/zcash/zips/blob/main/zip-0317.rst, where the tex doesn't render

@@ -4951,11 +5031,10 @@ var dummyP2PKHScript = []byte{0x76, 0xa9, 0x14, 0xe4, 0x28, 0x61, 0xa,

// EstimateSendTxFee returns a tx fee estimate for sending or withdrawing the
// provided amount using the provided feeRate.
func (btc *intermediaryWallet) EstimateSendTxFee(address string, sendAmount, feeRate uint64, subtract bool) (fee uint64, isValidAddress bool, err error) {
func (btc *baseWallet) EstimateSendTxFee(address string, sendAmount, feeRate uint64, subtract bool) (fee uint64, isValidAddress bool, err error) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This makes the electrum wallets TxFeeEstimators. Anything wrong with that @chappjc?

Copy link
Member

Choose a reason for hiding this comment

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

Not in principle. With your move of estimateSendTxFee to be a baseWallet method, it looks like the existing (*electrumWallet).listUnspent is adequate.

@buck54321 buck54321 force-pushed the zec-fees branch 2 times, most recently from 86a225e to c5eeb35 Compare May 9, 2023 20:37
@buck54321
Copy link
Member Author

Replaced by #2553

@buck54321 buck54321 closed this Oct 3, 2023
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