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 ...
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 ...
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 ...
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". ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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:...
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: ...
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.
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, ...
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) ...
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 ...
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 ...
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 ...
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), ...
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.
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 ...
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 ...
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 ...
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 ...
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 ...
4
votes
Accepted
P2SH address decoding
Here is the example
of the transaction from the question
the redeem script is: ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
p2sh × 224script × 47
multi-signature × 35
transactions × 31
segregated-witness × 28
bitcoin-core × 25
p2pkh × 23
signature × 16
address × 15
raw-transaction × 14
p2wpkh × 12
p2wsh × 11
input-script × 11
bip32-hd-wallets × 9
wallet × 8
hash × 8
bech32-address × 8
blockchain × 7
bitcoind × 7
bitcoinj × 6
python × 5
utxo × 5
private-key × 4
litecoin × 4
public-key × 4