Comments (10)
Lets leave it as a function though, no need to bikeshed this.
from rust-bitcoin.
I used this blog post to learn about this stuff: https://bitcoin.stackexchange.com/questions/103654/calculating-fee-based-on-fee-rate-for-bitcoin-transaction#103661
from rust-bitcoin.
Reading previous discussions should answer your questions but briefly:
does not consider weather we are adding this input to a legacy or segwit transaction
The caller is responsible for setting the correct satisfaction weight based on this
What is satisfaction_weight?
Total weight of witness + script_sig when the input is fully signed
Why is this not a method on
TxIn
Because TxIn
doesn't contain amount. And you will soon see a potential solution I'm about to push, just checking some things...
or on
Transaction
Because Transaction
has multiple inputs and outputs.
on tx it would solve the segwit thing
It wouldn't because of P2SH-P2WPKH where you're unable to tell whether it's segwit or not just from looking at the transaction alone.
The function is a minimal primitive used for coin selection. Among other things it can determine whether spending a particular output is worth it.
from rust-bitcoin.
- How can it be correct if it does not consider weather we are adding this input to a legacy or segwit transaction?
The satisfaction weight will take this into account.
- What is
satisfaction_weight
? Why the term "satisfaction" - I thought we used this term already to satisfy a script.
Yes, and satisfying a script requires a certain amount of weight. Note that rust-bitcoin doesn't have any real facilities for script satisfaction; either you use a fixed template and manually construct witnesses, or you can use rust-miniscript or similar.
- Why is this not a method on
TxIn
or onTransaction
(on tx it would solve the segwit thing, on txin it kind of makes sense even though it doesn't useself
).
Logically speaking it belongs on TxIn
... but as you say, it doesn't actually use any part of the TxIn and therefore works as a standalone method. Maybe it should be a static method?
from rust-bitcoin.
Ok, thanks for the explanations, probably took more of your time than I should have. I"ll add docs to the satisfaction_weight
argument to explain all that. Are we definitely happy with the term "satisfaction"?
from rust-bitcoin.
Logically speaking it belongs on
TxIn
I'd say TxOut
- it's operating on UTXOs where O means output.
Maybe it should be a static method?
Then we enter a huge flamewar whether it should be on TxOut
or TxIn
. :D
Are we definitely happy with the term "satisfaction"?
Do you have an alternative? I can't come up with any.
from rust-bitcoin.
We are calculating the weight of adding a TxIn
type (and we use weight of OutPoint
and Sequence
), sure Amount
comes from a UTXO but this is the same problem we always have with the nomenclature of input/output - one transactions ouput is the next ones input.
from rust-bitcoin.
We could just implement it on ExtendedTxIn
from #2347 :D
But really, if we can come up with good Extra
that can represent known satisfaction weights we can have it as a method that doesn't require other arguments than self
.
from rust-bitcoin.
@tcharding thanks for the questions and suggestions to improve this. Reading the comments on the PR #2230 may also help with some of your earlier questions. In particular:
The effective_value is used to calculate how much a particular output contributes to a target spend amount. Therefore, the effective_value returns the net amount, that is, the output amount minus the overhead to spend the output. The overhead to spend the output is the fee. In order to calculate the fee, the size of the input which consumes the output is calculated as the input base_weight plus the size of the output once the spending conditions are satisfied (the satisfaction_weight) multiplied by a fee_rate. Lastly, subtract the fee from the output value to find the effective_value.
Happy to discuss any other questions or additions.
from rust-bitcoin.
@yancyribbens while you're here, check out the ExtendedTxIn
type in #2230 It could represent a UTXO.
from rust-bitcoin.
Related Issues (20)
- Remove usage of wildcard imports
- Cannot get DerivationPath serialised from root anymore HOT 12
- psbt: it should fail when there is an extra data HOT 3
- Epic: Re-write the `hashes` API HOT 4
- Epic: Make it possible for `rust-bitcoin` to depend on `rust-miniscript` HOT 1
- `psbt::raw::Key`'s `type_value` field should be serialized as `VarInt` HOT 12
- `VarInt` can encode sizes that are greater than max allowed by Core HOT 4
- Doc: Capitalization of proper nouns HOT 3
- bip158: unrelated but it'd be better to just feed the data into engine rather than copying arrays around.
- Determine API for `sha256::Midstate` HOT 4
- How to stabilize most important stuff in two weeks HOT 15
- bitcoin-fuzz MSRV different from bitcoin HOT 11
- fuzz.sh fails with unbound local variable HOT 3
- What to do about our private `prelude` module HOT 8
- Readme outdated/contrib/test.sh no longer exists HOT 11
- Do we actually need hash tagging? HOT 1
- Strategy for dealing with `as u64` casts HOT 1
- Amount to_string Precision HOT 5
- Deprecate&remove `Amount::fmt_value_in`? HOT 2
- Write a proptest to check Amount formatting.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust-bitcoin.