2c7335fecc Remove duplicated code from merge (Pablo Greco)
Pull request description:
Remove duplicated code that looks like a bad merge in the 21-22 timeframe
ACKs for top commit:
delta1:
utACK 2c7335f
apoelstra:
utACK 2c7335fecc
Tree-SHA512: 19332412530b898783de7ba705108552dcb17a8e54987d9c916f15aeb33cd94063a3957578edd77fedc97650b224949e5e13a5e25cc045959f3d72567a773e5a
c6e074e25b liquidtestnet: Fix chain name in windows installer (Pablo Greco)
d0f391cfdb liquidtestnet: Add style for Elements-Qt (Pablo Greco)
48ddfbf8d7 liquidtestnet: Add fixed seeds (Pablo Greco)
3b34c8e927 liquidtestnet: Add seed nodes (Pablo Greco)
0d1964766f liquidtestnet: Accept multi OP_RETURN (Pablo Greco)
f955cb3d9c liquidtestnet: Add chainparams (Pablo Greco)
0fa20d006d CCustomParams: Move some defaults away from UpdateFromArgs (Pablo Greco)
e9df51121f Add text version of the fixed seeds for liquidv1 and liquidtestnet (Pablo Greco)
Pull request description:
Currently using liquidtestnet requires a big config file, which is error-prone and uncomfortable for users, this MR adds support for just using `-chain=liquidtestnet`.
There are a few things that need to be discussed/addressed
1. Main port (currently set to 18891 because that's the one used originally, and the one that's configured in `liquidtestnet.com`)
1. RPC and extra ports, I just chose some non-overlapping ports that are "close" to the ones in the other liquid/elements networks.
1. Icon color, I just used something different than `liquidv1` and `elementsregtest`, suggestions accepted 😉
1. `liquid-testnet.blockstream.com` is still using port 18892, it will be changed to 18891 soon.
1. both seeds are just CNAME dns records at the moment, they should be changed to real seed nodes (no changes in code required, but important for review)
ACKs for top commit:
delta1:
ACK c6e074e
wintercooled:
ACK c6e074e25b
apoelstra:
utACK c6e074e25b
Tree-SHA512: 48c17b8b90ba5a33ae987935ffb368737167f6ca5ae772f6dd8c0c5e7efb39355d81e2677cd02d3e22984f2592fdd67caaf838003902b3c827f6ade01f18a040
Make these two functions available to external callers.
CreateBlindValueProof is a wrapper around the static function to avoid
requiring callers to parse things into secp256k1 objects.
It is arguable whether attempting a value proof without an asset
commitment should be treated as incomplete or incorrect blinding. Since
the asset commitment is required to produce the value proof in the first
place, failing to provide it in the source PSET and thus at this call
site is treated as an error.
This does not change the existing behaviour since a missing asset
or value commitment in this function would already cause it to fail.
Future work on the blinding iterface should likely return the blinding
state directly from the verify calls and remove the duplicated mapping of
blinding error codes to transaction blinding error codes, instead of the
verify functions returning just true/false.
Prior to coin selection we need to indicate that the issuances will take
extra space, otherwise we may fail to select enough coins to cover our
fees, triggering the new "fee needed exceeds fees available" assertion.
The Elements 22 blinding logic has an edge case where when we drop change,
leaving only a single blinded output, we recompute a bunch of blinding
data to handle the potential for us to have 0 inputs and 1 output to blind.
(BlindTransaction will fail in this case because it cannot make the
transaction balance with only one output to mess with.)
In this recomputation, we dropped more data than we meant to, causing us
to incorrectly blind an output.
First, this reverts commit ca2d72ae8b to reinstate
an assertion that was added in Bitcoin #22686. It did not compile because our
`change_and_fee` variable is a map rather than number; I changed it to use
`map_change_and_fee.at(policyAsset)` to match the equivalent change 2 lines down
from a5d97b363b (merge of Bitcoin #22008).
Then fix the following bugs:
1. Change the new test in rpc_fundrawtransaction.py to bump the -maxtxfee value,
which we'd otherwise exceed, failing the test and masking actual failures.
(This was just caused by the extreme fee settings of the test combined with
Elements' large transactions.)
2. Change the fee-output size estimation for `tx_noinputs_size` to be 46 rather
than 44 bytes; we forgot that even null surjection/rangeproofs need a 0 byte
when output witnesses are present. This mistake triggered the new assertion.
3. Correct the logic in which change outputs are sometimes dropped even when
they are the only blinded output in a transaction with blinded inputs. This
would cause the new test to fail with `bad-txn-inputs-ne-outputs`; I'm very
surprised that no existing tests hit this.
(I have an existing comment block in this code where I "promise" that I had
a good reason for doing something mysterious related to blinding. I was not
able to reverse-engineer my intention here, though I think it is related to
this, but since I couldn't understand it I just left this block intact and
worked around it.)
4. This then triggered the assertion again since the coin selection code
assumes that sufficiently-small change will always be dropped. If we prevent
this drop we will have under-funded the transaction.
To fix this we add Yet Another Flag `may_need_blinded_dummy` in which we add
extra weight to `tx_noinputs_size` in the case that we're doing a blinded tx
but have no blind destinations. We turn this off after coin selection if it
turns out that we don't have any blinded inputs, though ofc at that point
much of the damage/inefficiency has already been done..
5. Fix some constants in other functional tests which assumed precise fee
calculations; these precise values changed because of fixes (2) and (4).
There is one new FIXME, which is that the "dummy change" value will now be a
zero-valued OP_RETURN but we still put a full-size rangeproof and surjection
proof on it. There is some plausible privacy benefit to this but not much,
and wasting 5000+ bytes rather than the ~65 needed for an exact-value proof
is not worth it. We will fix this in the future when we overhaul the wallet
blinding logic.
When the fee is not subtracted from the outputs, the amount that has
been reserved for the fee (change_and_fee - change_amount) must be
enough to cover the fee that is needed. It would be a bug to not do so,
so use an assert to make this obvious if such a situation were to occur.
Github-Pull: bitcoin/bitcoin#22686
Rebased-From: d9262324e8