calculate – Earlybirds Invest https://earlybirdsinvest.com Latest Crypto News Sun, 06 Jul 2025 05:37:38 +0000 en-US hourly 1 https://wordpress.org/?v=6.9.8 https://i0.wp.com/earlybirdsinvest.com/wp-content/uploads/2024/12/cropped-New-Project-2024-12-17T235703.455.png?fit=32%2C32&ssl=1 calculate – Earlybirds Invest https://earlybirdsinvest.com 32 32 240146708 How do I calculate the number of expected SATs and arrive at a probabilistic payment flow? https://earlybirdsinvest.com/how-do-i-calculate-the-number-of-expected-sats-and-arrive-at-a-probabilistic-payment-flow/ https://earlybirdsinvest.com/how-do-i-calculate-the-number-of-expected-sats-and-arrive-at-a-probabilistic-payment-flow/#respond Sun, 06 Jul 2025 05:37:37 +0000 https://earlybirdsinvest.com/how-do-i-calculate-the-number-of-expected-sats-and-arrive-at-a-probabilistic-payment-flow/ Take a look at the following network example:

Enter the image description here

Assume S I want to send it 3 Sit down R. You can assume that further S Each local channel has sufficient liquidity 3 soil. It also assumes channel fluidity (A,R), (B,R) and (C,R) It is distributed evenly.

One optimally reliable payment flow in this diagram looks like this:

1 sat: S --> A --> R   probability: 2/3
2 sats: S --> B --> R  probability: 3/5

This flow has a total probability 2/3*3/5 = 2/5 = 0.4 = 40%

question:

How to calculate the expected value of the arrival of Satoshu R if S send 3?

Option a

(I already know I’m wrong, but I think some people have similar initial thoughts, so I’ll write it down)

At first I thought this was just right 3 sats * 2/5 = 6/5 sats = 1.2 sats This is obtained by multiplying the amount of transmission with the probability of flow. This seems strange when sending two SATs S-->B-->R There is a chance of 3/5 And with the above reasoning 2 sats * 3/5 = 6/5 sats = 1.2 sats. The expected value of 1 is sitting along S-->A-->B The path is bigger 0 This is inconsistent with the expected additive.

Option b

Starting with the above reasoning, we add the expected value to the broken path.

E(3 sats) = 1 sat * 2/3 + 2 sat * 3/5 = 10/15 sats + 18/15 sats = 28/15 sats

Option c

Of course, two Satoshi Passes S-->B-->R You don’t need to send it as a single onion as an onion, but you can send it as two onions each with one soil.

The first is the probability 4/5 The second is a conditional probability 3/4 This is widely explained in this issue. You should be able to add these expectations using the logic in option B. Therefore S--> B --> R It is calculated as follows:

E(2 sats) = 1 sat * 4/5 + 1 sat * 3/4 = 31/20 sats 

Add one Saturday onion S-->A-->R That was 2/3 soil

We expect to have

E(3 sats) = 31/20 sats + 2/3 sats = 93/60 sats + 40/60 sats = 132/60 sats = 33/15 sats

This is 5/15 sats = 1/3 sats More than the answer to option b

Option d

Worse, I’m confused if there’s a chance that the expectation of analyzing two SAT onions in option C into two SAT onions could be linearly added, as the second onion is conditional to have two SAT onions in the channel. If the first onion fails, the second onion certainly fails. Therefore, in order to send such two Saturday onions, you need to calculate the expected value.

E(2 sats) = 1 sat * 4/5 + 1 sat * 3/5 = 7/5 sats

This gives you the following total expected value:

E(3 sats) = 2/3 sats + 7/5 sats = 10/30 sats + 21/15 sats = 31/15 sats

thought

There are results just for comparison

  • Option a: 18/15
  • Option b: 28/15
  • Option c: 33/15
  • Option d: 31/15

Option B certainly seems correct, but it makes sense to further analyze the two SATS onions. In the simulation, option D appears to be correct. This is a bit surprising to me. Using the formalism of probability theory, the difference between the 2 SAT paths is as follows:

  • Option c: E(2 sats) = 1 sat * P(X>=1) + 1 sat * P(X>=2 | X >= 1)
  • Option d: E(2 sats) = 1 sat * P(X>=1) + 1 sat * P(X>=2)

As mentioned earlier, the simulated setting indicates that option D is correct, but that is very surprising to me as I expect the second term to be a conditional probability.

]]>
https://earlybirdsinvest.com/how-do-i-calculate-the-number-of-expected-sats-and-arrive-at-a-probabilistic-payment-flow/feed/ 0 46031
How do I calculate the transaction fee for a CALL to CALLEPSEPSBT()? https://earlybirdsinvest.com/how-do-i-calculate-the-transaction-fee-for-a-call-to-callepsepsbt/ https://earlybirdsinvest.com/how-do-i-calculate-the-transaction-fee-for-a-call-to-callepsepsbt/#respond Sat, 14 Jun 2025 00:30:49 +0000 https://earlybirdsinvest.com/how-do-i-calculate-the-transaction-fee-for-a-call-to-callepsepsbt/ When my user calls my app, he is passed as an input parameter. Call it to create a PSBT createpsbt(). Full control over input and output decisions. For example, I don’t call walletcreatefundedpsbt()Because I don’t want to choose input on my behalf to bitcoind. I have a chicken and egg problem in that I need to call createpsbt() To determine the size of TX in bytes, you must specify the fee amount before the call createpsbt(). The best solution I can think of is to perform a dummy call createpsbt() Use the dummy fee value to measure the size of the TX and make the actual call createpsbt() After calculating the fee amount correctly. Is there a better way?

edit: I want to use all utxos. You need two outputs. One receives a fixed amount and the other receives a change in the fee. I have tried many spells, I can’t make it work. Here is my latest attempt:

raw_psbt = rpc.walletcreatefundedpsbt(
    # all UTXOs, as returned by listunspent():
    inputs,
    # one recipient: ( { addr : amount } )
    outputs,
    0,  # locktime
    {
        "replaceable" : True,
        # I would like for the change less the fee to go here:
        "changeAddress" : xxx,
        "includeWatching" : True,
        "feeRate" : 0.005,
    }
)

This fails Signing transaction failed (-4). Are you thinking about what I’m doing?

Edit #2: Cannot be used walletcreatefundedpsbt() As suggested below, in my environment, in order to create a PSBT, its input must be “solvable” in that function. Details of this link:

Error in walletcreatefundedpsbt & Unweldable utxos

So my original question remains unresolved at this point.

Edit #3: So I asked in Slack. The problem is that Bitcoin core does not have a way to calculate the TX size before TX is signed, since UTXOS cannot be expressed in 1) in a descriptor language, rather than 2) in a descriptor language. Apparently, you will need to do the calculations manually, as explained in the attached screenshot.Slack Chat

]]>
https://earlybirdsinvest.com/how-do-i-calculate-the-transaction-fee-for-a-call-to-callepsepsbt/feed/ 0 41887
How to calculate dust (closed) https://earlybirdsinvest.com/how-to-calculate-dust-closed/ https://earlybirdsinvest.com/how-to-calculate-dust-closed/#respond Fri, 14 Mar 2025 11:08:22 +0000 https://earlybirdsinvest.com/how-to-calculate-dust-closed/

Hello, I was trying to understand more about Litecoin dust. I came across https://theliteschool.com/lsc/staging-core-releases-and-litecoin-dust, but I don’t understand some things:

  1. What is the “minimum average output size”? What average? Transaction output? So, what is “minimum”? If you do the average, there is only one result…
  2. The same applies to “minimum average input size”.
  3. Does dust change from block to block? From transactions to transactions?

Also, this was a few years ago. Is that calculation still correct? Is the same for Bitcoin?

thank you

]]>
https://earlybirdsinvest.com/how-to-calculate-dust-closed/feed/ 0 25076