Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Hot answers tagged

50 votes
Accepted

My raw transaction destroyed 0.0284377 BTC. What did I do wrong?

Addresses that start with 3... are P2SH addresses, and they've been around for almost 6 years now. Historically they saw limited use - used by multisig wallets like Copay and GreenAddress. The ...
user avatar
26 votes

How to calculate transaction size before sending (Legacy Non-Segwit - P2PKH/P2SH)

Here are some calculations based on the Protocol Documentation. A Bitcoin Transaction is composed of the following: Version (4 Bytes) TxIn Count (1 ~ 9B) For each TxIn: Outpoint (36B) Script Length ...
user avatar
  • 2,378
16 votes
Accepted

Is it possible to convert an address from p2pkh to p2sh?

Is it possible to covert a p2pkh adrress to a p2sh adress? Don't. Addresses are determined by the wallet. It's the receiver's wallet saying "I will accept payment when it arrives at address X". ...
user avatar
12 votes
Accepted

How do bech32 addresses compare to P2SH addresses in transaction size?

bech32 produces smaller transactions than P2SH segwit transactions. one extra byte per output to create P2SH outputs than to create bech32 utxos (P2SH uses OP_HASH160 and OP_EQUAL in addition to a 20 ...
user avatar
  • 14.7k
11 votes
Accepted

Where are P2SH full redeem scripts stored?

Here's a working example that lays the groundwork for answering your question: Alice wants to pay Bob, so she asks Bob for an address. Bob wants to receive payment to a P2SH address. So Bob creates ...
user avatar
9 votes

Birthday attack on P2SH

Why does this document seem to imply that the birthday attack only works for multisig P2SH and then only for one of the signers? The birthday attack (to the best of my knowledge) requires that the ...
user avatar
9 votes
Accepted

What is the Witness and what data does it contain?

This structure contains data required to check transaction validity but not required to determine transaction effects. In particular, scripts and signatures are moved into this new structure. The ...
user avatar
  • 7,040
8 votes
Accepted

How do you spend a P2SH transaction?

You get this error because Bitcoin has tried to validate the script, and failed, because not all of the signatures necessary were added in the previous signrawtransaction. You can also tell this ...
user avatar
  • 28.6k
8 votes

Where the P2SH script gets written?

The script is maintained by the intended recipient; he is the one responsible to keep it and not to lose it. The nodes do not store any database of the scripts. The script is provided by the spender ...
user avatar
  • 992
8 votes
Accepted

What's the use of not relaying non-standard transactions if anyone can still use them using P2SH?

As you say, there are two separate concerns here: There are some scripts that might cause harm to the network. There are some scripts that might make future upgrades harder. For the case of harm to ...
user avatar
7 votes

Pay to Script Hash Execution

I've been hunting for this information myself, and had to dig to the bitcoin source code to find the answer - couldn't find it anywhere else. There is a hardcoded logic in bitcoin for P2SH validation:...
user avatar
7 votes
Accepted

Difference between a SegWit address and a P2SH address

Until a P2SH-P2WPKH UTXO is spent and the redeemScript is exposed, a P2SH-P2WPKH address is indistinguishable from a non-segwit P2SH address (such as a non-segwit multi-signature address) Reference: ...
user avatar
  • 11.3k
7 votes

What the difference between old segwit (3) and new segwit address (bc)?

The difference lies in the encoding and the underlying representation in the transaction data stored on the blockchain. The 3-segwit addresses are known as P2SH-P2WPKH or P2SH-P2WSH. This stands for ...
user avatar
  • 16.4k
7 votes
Accepted

Why is my P2SH sigScript field prepended with 0x00?

OP_CHECKMULTISIG contains a bug which consumes one extra element from the stack. Due to this, an additional OP_FALSE (0x00) is pushed for multisig scripts to make the script evaluation valid.
user avatar
  • 16.4k
6 votes
Accepted

Multisig created from Multisig address

No. A "multisig address" is really a hash of a redeem script encoded as a P2SH address. Redeem scripts can't be nested, which means you can't include one redeem script inside another redeem script, ...
user avatar
6 votes
Accepted

Does OP_HASH160 consume the top stack element?

Yes, OP_HASH160 consumes the top stack element and replaces it with its hash. So how does P2SH work, if the script is consumed after HASH160 runs? Here's how P2SH transactions are processed: ...
user avatar
  • 28.6k
6 votes
Accepted

Which security threats in P2PKH lead to the use of P2SH?

The only security concern of P2PKH is that it only requires 1 key to spend coins paid to it. P2SH just lets you be even more secure by easily putting more conditions on the redemption of your coins, ...
user avatar
  • 13.7k
6 votes
Accepted

What is meant by "relaxed standards" for P2SH redeem scripts in Bitcoin Core 0.10.0?

What are the specific changes which have been made (ie relaxed standards)? Gavin Andresen made this pull request proposing the change, as well as this rationale document describing why he supported ...
user avatar
6 votes
Accepted

What the difference between old segwit (3) and new segwit address (bc)?

There's no big difference for users between the two. The fee is lower while using native Segwit address (bech32), and the address format differs. Let's look at the motivations of bech32 address ...
user avatar
  • 3,559
6 votes
Accepted

How can one see if an address is multisig?

There are different types of addresses in Bitcoin. The simplest format is called pay-to-public-key-hash (p2pkh) which locks funds to a single private key. Another is called pay-to-script-hash (p2sh), ...
user avatar
  • 62.5k
6 votes
Accepted

Bitcoin-qt getnewaddress returns address starting with 2

You are using testnet. Addresses starting with "M", "N", "2" and "tb1" are testnet addresses.
user avatar
  • 76
5 votes
Accepted

If I was developing a Bitcoin wallet, should I support both legacy and compatibility addresses?

Displaying two would be justified if you were asking about a BC1 p2wpkh vs a 3xxx p2sh(p2wpkh) because not everything supports BC1 but its pretty good to use when supported. Displaying two isn't ...
user avatar
  • 7,449
5 votes
Accepted

Why are P2WSH addresses larger than P2SH addresses?

Because P2SH addresses are too short to provide typically desirable levels of security security level we expect from Bitcoin, against certain attacks. On top of that, they use bech32 encoding rather ...
user avatar
5 votes
Accepted

Why P2SH seems to be never smaller than 34 characters, unlike P2PKH?

Because Base58 initial 1s carry 8 bits of data, but P2SH addresses cannot be represented with a string with initial 1s so it starts with 3 which, like all other cases & characters, encodes 5.86 ...
user avatar
  • 9,789
4 votes
Accepted

What new transactions are possible with 15 operations?

It's not exactly "15 operations"... The Bitcoin address is not really a public key, but a special script that is built from special commands. From those commands you could build really weird ...
user avatar
  • 245
4 votes
Accepted

P2SH address decoding

Here is the example of the transaction from the question the redeem script is: ...
user avatar
  • 1,530
4 votes
Accepted

How does a P2SH script get executed?

Does P2SH validation create a second stack using a copy of the redeem script, and then validate that stack before moving on to deserializing the redeem script (and then validating that script as ...
user avatar
  • 60.6k
4 votes
Accepted

How is it possible that the same WIF Private Key generates two different addresses?

The same private key can be used to derive a couple of different addresses. For example, there will be a different address generated depending on whether you use a compressed or uncompressed public ...
user avatar
  • 17.2k
4 votes

What is the Witness and what data does it contain?

For the segwit variants of an output (P2PKH becomes P2WPKH and P2SH becomes P2WSH), the witness contains the same data that would be found in the scriptSig. For P2PKH, in the scriptSig, you would have ...
user avatar
  • 60.6k
4 votes

How can one see if an address is multisig?

Once an address has been spent from, the script that is used to create the P2SH address will be revealed in the spending transaction. So any addresses that have the 'm-of-n' information listed on that ...
user avatar
  • 17.2k

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