Both answers by James C. and sanket1729 are very good, but I wanted to give a very high-level answer:
Miniscript is an intermediate more structured representation for actual Bitcoin Scripts. It is useful as a toolbox because it simplifies static analysis of scripts, and things like generic signing.
The policy language is intended to simplify designing ...
At a high level:
The policy is compiled to Minsicript.
Miniscript is encoded to bitcoin Script. (One to One Mapping)
Bitcoin Script is decoded back to Miniscript. (One to One Mapping)
Policy and Miniscript can both be lifted to another representation
for static analysis.
Following invariants are respected in Miniscript:
Let ms be a miniscript, s be ...
Miniscript doesn't compile down to script. It encodes a subset of all Bitcoin script. It is a (very crafty) template language which reduces the Bitcoin script language to specific script expressions which are composable, which means the properties of a miniscript expression only depend on the property of its children. Properties include malleability, ...
A bit of a meandering answer to the question, and to answer a side question: fundamentally what is a scaling solution?
OP_CTV does not increase the block space. Transactions using generally will use more block space actually (although it need not be a large amount), and relay can be optimized to equivalent.
But scaling is more than just a block size ...
Let's run through the program.
The stack starts as <A sig> <A pubkey>.
You run OP_DUP. The stack is now <A sig> <A pubkey> <A pubkey>.
You run OP_HASH160. The stack is now <A sig> <A pubkey> <A pubkeyhash>.
You push (A expected pubkeyhash). The stack is now <A sig> <A pubkey> <A pubkeyhash> &...
It has always been the case that the full Bit Machine would be "exposed" by allowing arbitrary Simplicity. This is because the combinators that let you compose the high-level jets are exactly the same combinators that define low-level Simplicity. Thus even if only a few high-level jets are chosen to be exposed, it would still be the case that the low-...
Bitcoin uses a stack based language due to which the logical condition that will execute the IF or ELSE statements comes prior to the operator IF or ELSE. Let's take both your cases one by one and see how it gets executed on the stack.
Case 1: ScriptSig: 0 <Alice's signature> <Bob's signature> 0
The stack starts at 0 <Alice's signature> &...
For this answer, I will mainly focus on static analysis of computation resources such as memory use and time.
In Simplicity, we have a separation between the Simplicity language and the language of the Bit Machine with a formal translation from the Simplicity language to the Bit Machine language (see Figure 2 from the whitepaper). This translation has been ...
As noted in BIP 143, the CODESEPARATOR opcode operates by truncating the scriptCode value that is included in the digest. While rarely used, CODESEPARATOR does provide a method to create signatures that are bound to specific code paths taken by Script, even when the same pubkey key used for redeeming the UTXO.
If the scriptCode were removed from the digest ...
In general, changes to policy rules are not specified in BIPs. They're up to individual clients anyway.
BIP16 is not obsolete, though its description of the standardness rules in Bitcoin Core is outdated by now. However, its consensus rules (i.e., what is valid in a block, not what will be relayed as individual transactions) are unmodified since it ...
Any address that a spender will send to is provided by the receiver. As the owner of the address, the receiver knows these details and will be able to provide the correct sending instructions to the spender. This holds true even for the outdated original multisig construction that required the spender to know the pubkeys, but today most multisig transactions ...
One of the issues with encoding P2PK outputs as an address is that they can be very long. P2PK can have both compressed and uncompressed keys. Uncompressed keys are 65 bytes, which means that the resulting address would be very long. In fact, this length is probably why P2PKH exists in the first place: as a way to have short strings as addresses. So P2PK ...
Yes, this is possible. You can construct a script such as:
This will allow key1 to freely spend the coins, but if a signature from key1 is not present it also allows any 3 of the ...
Your input txid output index is 5 bytes, when it should be 4 bytes. Just remove the extra 00 byte and the transaction will not pop an error. However, you might need to sign this transaction again as signature involves signing the entire serialized transaction as a message and by changing the txid outpoint you will change the message that is signed.
There are three ways in which that offered HTLC output can be redeemed: Revocation using the revocation public key (the example you mentioned), redeemed using a valid payment preimage or back to the local node after the timeout.
Redeemed using a valid pre-image by remote node:
The stack starts at <remotehtlcsig> <payment_preimage>
Since the ...
Yes, this is the problem.
Pre-segwit there is a standardness rule in Bitcoin Core that requires a single element only on the stack after execution.
In P2WSH, this is part of the consensus rules.
The reason for this is that without such a rule it is trivial to malleate any transaction: just prefix the scriptSig with additional garbage elements, which would ...
A P2SH locking script on an output has the following structure:
OP_HASH160 <scripthash> OP_EQUAL
The address comes for this comes from the <scripthash>, creating a "3address". This is the standard format for a P2SH, so you can identify it and work out the address from there.
There is no specification, or really documentation, for Miniscript other than sipa's website. There is no "correct" or singular way to compile a miniscript policy into miniscript. The two existing implementations actually go about compiling in different ways, although both arrive at the same result (occasionally they differ, but the two results are ...
SIGHASH_ALL | SIGHASH_ANYONECANPAY signs the outputs. So the entrepreneur cannot change the output, as it would invalidate the signatures on all the inputs he received.
There is another way he can bypass this though - if he has 500 BTC himself (or can borrow that amount very briefly) - he can contribute that himself, getting away with raising only 500 BTC ...
This answer was provided by Pieter Wuille (@pwuille) on Twitter.
Conceptually it doesn't make sense, because script conditions are monotonic. What would and(pk(A),not(pk(B))) mean? "B does not sign" is trivially satisfied; B would just never bother signing.
Similarly, not(older(N)) would not mean younger(N). There (intentionally) does not exist a way in ...
In modern times, this problem is solved using P2SH (and later P2WSH). It means the sender only needs to know a hash of the actual script the receiver wants to use, which has its own address format so it's easy to convey.
If your question is how was this done before P2SH: the answer is simply that multisig was not used in practice. Note that P2SH was ...
I want to add my propose to this solution.
I have released the new parser called SpyCBlock, this is the simple parser blk file (multiprocessor).
With this parser is possible to serialize the blockchain into JSON, so blkxxxxx.dat -> blkxxxxx.json (also another type of serialization).
I think with the JSON version is possible to run your analysis and I have ...
It seems that bitcoin-iterate implements your second suggestion:
This is some fast code to iterate over bitcoind's block files to extract blockchain data from the main blockchain.
But as far as I know it doesn't allow your to filter by script. That would be a nice addition to the project, I think. Or you could write something similar that did that.
Check the Script wiki would be helpful. I once did this by hand, here's the process.
First, put the unlocking script on top of the locking script,
# To remote node with revocation key
OP_DUP OP_HASH160 <RIPEMD160(SHA256(revocationpubkey))> OP_EQUAL
From what I understand, a non-SegWit P2PH address is obtained by hashing the redeem script
I had the same problem and I have resolved it with this C++ code, and I think this code is self-describing.
If you have the ScriptPubKey extract from the blk file, this is code calculate the correct address P2SH.
string opcode = hex.substr(0, 2);
I'd say that's just because nobody programmed it. Bisq community for example is short on programmers so they concentrate on the essentials. Companies have no interest in the development or shy away from the legal risk, where they are increasingly forced to perform financial police duties similar like banks (KYC/AML). Hopefully the Bisq DAO brings enough ...