Hot answers tagged

52 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 ...
Pieter Wuille's user avatar
43 votes

What is P2PK, P2PKH, P2SH, P2WPKH - ELI5

P2PKH: "Pay To Public Key Hash" This is how transactions are made. You are requiring the sender to supply a valid signature (from the private key) and public key. The transaction output script will ...
Monstrum's user avatar
  • 1,334
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 ...
rny's user avatar
  • 2,398
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". ...
Pieter Wuille's user avatar
13 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 ...
Chris Moore's user avatar
  • 14.7k
11 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 ...
Pieter Wuille's user avatar
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 ...
David A. Harding's user avatar
10 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 ...
JBaczuk's user avatar
  • 7,278
10 votes

What is the largest multisig quorum currently possible?

The rules governing this depend on the type of script used and whether that script is in the output script, in a P2SH, in a P2WSH, or in P2TR. Additionally, the rules are more restrictive for ...
Andrew Chow's user avatar
  • 67.5k
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 ...
Nick ODell's user avatar
  • 29.2k
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 ...
dionyziz's user avatar
  • 1,012
8 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 ...
Raghav Sood's user avatar
  • 16.9k
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 ...
David A. Harding's 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:...
Jan Koriťák's 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: ...
meshcollider's user avatar
  • 11.7k
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.
Raghav Sood's user avatar
  • 16.9k
7 votes
Accepted

Why are P2WSH addresses larger than P2SH addresses?

Because P2SH addresses are too short to provide the typically desirable level of security we expect from Bitcoin, against certain attacks. On top of that, they use bech32 encoding rather than base58, ...
Pieter Wuille's user avatar
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

Did the P2SH BIP-0016 make some Bitcoin unspendable?

Even before BIP-0016 activation, there were some outputs that matched the P2SH pattern. Only one of them was spent before activation, and the rest have likely been made unspendable by the BIP-0016 ...
bca-0353f40e's 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 ...
Adam's user avatar
  • 3,639
6 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 ...
chytrik's user avatar
  • 17.9k
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), ...
Murch's user avatar
  • 71.7k
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.
Zoy's user avatar
  • 76
6 votes

What is the purpose of P2WPKH-P2SH?

P2SH-P2WPKH addresses can only be created by segwit-compatible wallet software. However, sending to a P2SH-P2WPKH works with any P2SH-compatible wallet, as the address is indistinguishable from (and ...
Pieter Wuille's user avatar
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 ...
G. Maxwell's user avatar
  • 7,676
5 votes
Accepted

How is OP_CHECKTEMPLATEVERIFY a scaling solution

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 ...
Jeremy Rubin's 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 ...
MCCCS's user avatar
  • 10.1k
5 votes
Accepted

Can The Redeem Script Consist Of Only 1 Public Key In P2SH Transactions:

Before the adoption of BIP16: Pay to Script Hash, multisig was possible, but only in the form of bare outputs. The multisig would be directly defined in the ScriptPubKey (the output script). This had ...
Murch's user avatar
  • 71.7k
4 votes
Accepted

P2SH address decoding

Here is the example of the transaction from the question the redeem script is: ...
Albert S's user avatar
  • 1,630
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 ...
Andrew Chow's user avatar
  • 67.5k

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