7 votes
Accepted

What are the scriptPubKey, scriptSig, redeem script and witness for the various output types?

This was answered during the Bitcoin Core PR review club on July 7th 2021 hosted by Gloria Zhao (who also provided this table). The <public key> in the P2TR (key path) and P2TR (script path) ...
Michael Folkson's user avatar
7 votes
Accepted

Why inputs' scriptSig are stripped before the whole transaction being signed?

Because they can't be. The scriptSig values contain the signatures. If they were included in the message being signed, you'd need signatures that sign themselves. That's not possible.
Pieter Wuille's user avatar
6 votes
Accepted

What prevents OP_SUCCESS from being used nefariously?

The UTXO's scriptPubKey commits to the script(s) that are permitted for spending, so you can't just pick an OP_SUCCESSx script and spend with that - the coins have to be sent to an address that ...
Pieter Wuille's user avatar
5 votes
Accepted

How do I fix my check-multisig if-else output script?

OP_IF consumes a number from the top of the stack. The OP_IF will evaluate to true if the number is not 0, and to false if the number is 0. H/T for this answer by David Schwartz, and to Pieter ...
Murch's user avatar
  • 73k
5 votes
Accepted

What is the maximum number of bytes the coinbase scriptSig (coinbaseaux) can hold?

The maximum is 100 bytes and is checked and defined here: https://github.com/bitcoin/bitcoin/blob/master/src/consensus/tx_verify.cpp#L195
Andrew Chow's user avatar
  • 68.6k
5 votes
Accepted

How can the genesis block contain arbitrary data on it if the script is invalid?

For four reasons (each of which individually would be enough): The genesis block is valid by definition. It is never validated. It is just by definition the first block of the chain, and every other ...
Pieter Wuille's user avatar
5 votes
Accepted

Why is concatenating scriptPubKeys and scriptSigs unsafe?

It was possible (see the infamous "1 RETURN bug") because the RETURN operand used to stop the execution of the Script. So simply pushing 1 in the scriptSig and RETURNing would make the ...
Antoine Poinsot's user avatar
4 votes
Accepted

What prevents anyone from spending utxos from a native segwit address?

Segwit is a soft fork. A supermajority of miners have agreed that they will not include such transactions in their blocks, and will orphan any block that does include such a transaction. If you send ...
Nate Eldredge's user avatar
4 votes

Decoding ScriptSig

This is a 5 input one output multisig transaction. The decoding of the first sigscript ...
pebwindkraft's user avatar
  • 5,086
4 votes
Accepted

Why is the scriptSig formatted this way in the Genesis Block (inside function CreateGenesisBlock)

The scriptSig field of a coinbase transaction is special. It doesn't need any signatures at all, as no coins are being spent. The ability to produce new coins, which that input represents, is inherent ...
Pieter Wuille's user avatar
4 votes
Accepted

Processing bitcoin reward block's input transaction

This is the scriptSig of a coinbase transaction (the first transaction in every block is special; it doesn't actually spend anything but brings new coins into existence). Coinbase transactions have a ...
Pieter Wuille's user avatar
3 votes
Accepted

how to spend an utxo when the corresponding scriptsig is longer than 256 bytes?

The size is encoded as Compact size. These can be up to 9 bytes long and encode a size of anything between zero to 18446744073709551615 bytes. The rules are (according to serialize.h) : /** * ...
arubi's user avatar
  • 1,854
3 votes
Accepted

Step by step example to redeem a P2SH output required

The issue is, scriptsig contains the actual redeemScript instead of the serialized script as a push. The second error, the redeemscript contains an extraneous 0x00 value that should not be there as ...
arubi's user avatar
  • 1,854
3 votes
Accepted

How do I extract the address from a scriptPubKey?

Yes, to get addresses from scriptPubKeys, you will need to do a pattern match. There are only a small number of address types each with their own fixed scriptPubKey pattern. Keep in mind that not all ...
Andrew Chow's user avatar
  • 68.6k
3 votes
Accepted

Why we need to repalce the ScriptSig with the previous ScriptPubKey when calculate the per input signature hash?

Any data that is included in the sighash must be revealed to the signer. It also means that the signature itself directly commits to that information and so must be truthfully provided to the signer ...
Andrew Chow's user avatar
  • 68.6k
3 votes
Accepted

Where are transaction signatures beside the scriptSig?

Modern transaction, since SegWit, include signatures in a new field: the witness. The witness replaces the scriptSig. You can see in your example how txinwitness contains a public key and a signature ...
Antoine Poinsot's user avatar
3 votes
Accepted

What is prepended to the front of a ScriptSig and ScriptPubKey of a P2PKH transction?

In the serialization format, the input and output script are introduced by announcing the length of the script. So that 0x19 indicates that the length of the scriptPubKey is ...
Murch's user avatar
  • 73k
3 votes
Accepted

What fields of a coinbase transaction can be empty?

Would a block be accepted in which the coinbase transaction has an empty input scriptSig field? Is there an example of such? No, for unknown reasons there is a consensus rule that the coinbase input ...
Pieter Wuille's user avatar
2 votes
Accepted

Why is using a simple SHA1 in a scriptPubKey to emulate a "password" a security problem?

A simple Google search for eb271cbcc2340d0b0e6212903e29f22e578ff69b will reveal the preimage to you.
Pieter Wuille's user avatar
2 votes
Accepted

What is wrong with my ScriptSig? I get 64: scriptsig-not-pushonly

Your signature is not correct. First of all, its length can't be 74 bytes long. According to the Bitcoin wiki: Signatures are either 73, 72, or 71 bytes long, with probabilities approximately 25%, ...
sr_gi's user avatar
  • 3,192
2 votes

Testnet transaction - OPCODE MISSING OR NOT UNDERSTOOD error

quickly verifying: 410404f89c713f44615ad5fdc16f1ef8628351a1cce79ee96130a0e4a6eb09d05278cef28cb002a6ad2ad53181b01d03f931538488a7a689d83684e54822305205d5ba 41 hex equals 65. So the following string ...
pebwindkraft's user avatar
  • 5,086
2 votes
Accepted

Ho to identify a multisig transaction?

As you have found out correctly, the length field describes the following script length. Then the SigScript follows: ...
pebwindkraft's user avatar
  • 5,086
2 votes

How to create a p2sh transaction with a scriptsig of OP_true?

Here you have an example of a transaction spending from a P2PKH output and creating a P2SH output with an OP_1. And here you have the counterpart, a transaction spending from the first one (with an ...
sr_gi's user avatar
  • 3,192
2 votes

Transactions without signatures?

Transactions do not require a signature to be valid. Signatures are just a way of ensuring that the transaction is not going to be spent by anyone, but just by the person who holds the correct private ...
sr_gi's user avatar
  • 3,192
2 votes
Accepted

How do you create a scriptsig for a new raw tx?

Okay, turns out my research has led me to answer my own question, mainly from here though it did lack a bit of explanation or didn't explain, I think, as clearly as it could. So here's my reading/...
Mine's user avatar
  • 1,416
2 votes

Why are my Signature Scripts Different from my professors?

Signing the same piece of data with the same key typically produces different signatures unless you are using a deterministic signature scheme. Check if that is the case with the library you are using ...
Mike D's user avatar
  • 3,529
2 votes
Accepted

Is it safe to store bitcoins on p2sh (no multisig)?

Is it safe to store bitcoins in this address with this scriptsig ? That is actually the scriptPubkey, and it is only safe if you use a safe redeemScript. A P2SH script is a Pay-to-Script-Hash script,...
JBaczuk's user avatar
  • 7,328
2 votes
Accepted

Cant spend input with non-standart redeemscript (OP_CSV)

You must provide a scriptSig that, when executed with scriptPubKey results in a true (or any nonzero item) on the stack (and passes all verification ops). The scriptPubKey you need to satisfy (with a ...
JBaczuk's user avatar
  • 7,328
2 votes
Accepted

bitcoinj java library not decoding input addresses for some transactions

When an input redeems a P2PKH output (pay to an address starting with a 1), the format of the input script (the scriptSig) is: [signature] [public key]. Because public keys are included in both ...
Vecna's user avatar
  • 314
2 votes

Why did repeated "R" values occur in Bitcoin transactions before?

The R value is the result of EC point multiplication between the k value (known as the nonce) and the secp256k1 curve's generator point. It is effectively the public key for k. The only way that an R ...
Andrew Chow's user avatar
  • 68.6k

Only top scored, non community-wiki answers of a minimum length are eligible