9 votes

P2WSH, witness_v0_scripthash: how to derive an address

It's a Segwit output and hence does not have the address associated with it. The locking script for a Segwit transaction includes the witness version (0 in this case) and the redeem script (which is ...
Ugam Kamat's user avatar
  • 7,408
8 votes
Accepted

In simple terms, what are the major differences between P2WPKH and P2WSH bech32 addresses?

P2WPKH - This stands for "Pay To Witness Public Key Hash" and the scriptPubkey is OP_0 0x14 {20-byte-hash}, where OP_0 is the version, byte 0x14 is the size of the data, and the {20-byte-hash} is a ...
kawthuldrok's user avatar
7 votes
Accepted

Will P2TR make P2WSH obsolete?

As far as I can tell, P2TR is better than P2WSH in almost every way. I cannot think of a case in which it would be a significant advantage to use P2WSH over P2TR, except that P2WSH is already ...
Murch's user avatar
  • 75.3k
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
6 votes
Accepted

Can a coinbase transaction have a segwit output?

Other than the total value needing to be correct (no more than the block reward plus fees), the outputs of a coinbase transaction are completely unrestricted and act the same as any other transaction.
Claris's user avatar
  • 15.4k
6 votes

Constructing a P2WSH address from the BIP173 spec

First of all, what are you trying to do? Why do you need a P2WSH address? A P2WSH address (and P2SH addresses earlier) send coins to a script, which requires satisfying that script to decode. A ...
Pieter Wuille's user avatar
6 votes
Accepted

Support for P2WSH-wrapped P2TR addresses

In addition to the rationale given in BIP 341, I know of two arguments for not supporting P2SH-wrapped taproot outputs: backwards-compatibility: P2SH-wrapped segwit outputs were included in BIP 141 ...
jnewbery's user avatar
  • 1,060
5 votes
Accepted

how do you tell P2WSH invoice addresses apart from P2SH?

P2PKH addresses are 33-34 characters long, use Base58Check encoding, and (on mainnet) start with "1". P2SH addresses are 34 characters long, use Base58Check encoding, and (on mainnet) start ...
Pieter Wuille's user avatar
5 votes
Accepted

generate a P2SH-P2WSH address and spend output sent to it

bitcoin-cli's signrawtransaction expects a few arguments. You got most of them right, but forgot to add the details for redeeming the actual p2wsh part. Specifically for p2sh(p2wsh), you'd need to ...
arubi's user avatar
  • 1,864
4 votes
Accepted

Constructing a P2WSH address from the BIP173 spec

When you push items on the stack you must use an opcode to state how long the item you are pushing is. In this case you want to push 33 bytes so OP_PUSH33 Your script would be: OP_PUSH33 ...
Mike D's user avatar
  • 3,569
3 votes

Why are P2WSH addresses larger than P2SH addresses?

The encoding is bech32 not base58, which is slightly longer but vastly easier to type due to a lack of capital letters, and the inclusion of error correction rather than error detection. SegWit ...
Claris's user avatar
  • 15.4k
3 votes
Accepted

How to generate a P2WSH address

To generate a P2WSH address, you need to have some script. The easiest one you can use is a multisig script. You can do this with the command addmultisigaddress. If you do something like ...
Ava Chow's user avatar
  • 70.4k
3 votes
Accepted

Failing to construct transaction that unlocks P2WSH

The problem is this line: tx.witnesses.append(Script(['OP_5', 'OP_0', p2wsh_witness_script.to_hex()])) Perhaps confusingly, bitcoinutils uses the same API for scripts as it does for witness stacks (...
Vojtěch Strnad's user avatar
2 votes

P2WSH, witness_v0_scripthash: how to derive an address

Native segwit outputs (P2WSH and P2WPKH) do not currently have an address type, so there are no addresses for these outputs.
Ava Chow's user avatar
  • 70.4k
2 votes
Accepted

What is the signature digest for Segwit outputs

For signatures in P2WPKH and P2WSH spends, the sighash algorithm is described in BIP143. It is very different from the one used in legacy spends.
Pieter Wuille's user avatar
2 votes
Accepted

Help signing a P2WSH Multisig

I found the problem, in the bip143 tx digest preimage, the scriptCode needs to be preceded by the length of the scriptCode. In this case 0x47
Darius's user avatar
  • 789
2 votes

Generating P2WSH addresses | Is there a standard WitnessScript?

First of all, like pointed out in the first comment on your question, you're confusing the "witness program" and "witness script". The witness program for p2wpkh is OP_0 followed ...
Steven Roose's user avatar
  • 11.8k
2 votes
Accepted

Generate P2WSH native

Bech32 encoding, apart from the checksum, is a simple matter of converting base-256 (8-bits) to base-32 (5-bits). Base-256 is the byte array (octet string) that you get from a hash function. Only ...
Coding Enthusiast's user avatar
2 votes

What is the exact size and weight of a 2-of-2 P2WSH input?

TL;DR: A 2-of-2 P2WSH input should be conservatively estimated with 96 vbytes. Standard 2-of-2 P2WSH inputs generally weigh 95.5, 95.75 or 96.0 vbytes, depending on whether the r-values in the ...
Murch's user avatar
  • 75.3k
2 votes

What is "Witness"?

This is a transaction with three P2WPKH (native segwit v0 single-sig) inputs and a single P2WPKH output. For P2WPKH, the scriptPubKey (the locking script encoded in an output) contains a witness ...
Murch's user avatar
  • 75.3k
2 votes
Accepted

Is the witness `version` of a bech32 address required to "send spendable funds" to the address?

Can Alice still "send spendable funds" to Bob? If she recovers the witness version before converting the address to the scriptPubKey she puts in the transaction, yes. Otherwise, no. All ...
Pieter Wuille's user avatar
2 votes
Accepted

problem with unlocking P2WSH

The error you are encountering is the requirement for the minimal encoding of data. Specifically, your witness stack contains 0x00 for the number 0. However this is not the minimal encoding of 0. ...
Ava Chow's user avatar
  • 70.4k
2 votes

Where exactly is the Inscription media stored in witness signature?

I think this is explained at https://docs.ordinals.com/inscriptions.html Inscription content is serialized using data pushes within unexecuted conditionals, called "envelopes". Envelopes ...
RedGrittyBrick's user avatar
2 votes

Inscriptions with size less than 10Kb were seemingly possible before taproot, why did they become popular only now?

With P2WSH, one could seemingly use the same script structure ("envelope") OP_FALSE OP_IF OP_ENDIF to store up to ~10Kb of data in witness This is incorrect. The maximum standard witness ...
Antoine Poinsot's user avatar
2 votes

Inscriptions with size less than 10Kb were seemingly possible before taproot, why did they become popular only now?

There's really no reason inscriptions couldn't have been done with SegWit v0. The only difference would be that large inscriptions would have to be split across multiple inputs, making the ...
Vojtěch Strnad's user avatar
2 votes
Accepted

How can I spend a mix of UTXOs (p2sh, p2wpkh, p2wsh) along with a p2tr UTXO?

Since it is a segwit address you should use fromAddress2 = pub2.get_segwit_address() Also, while taproot (segwit v1) requires the scriptPubKey when signing, segwit v0 requires the script code; i.e. a ...
karask's user avatar
  • 2,540
1 vote
Accepted

What was the first ever P2WSH transaction?

I found it, using Blockchair as a free and easy search tool. The first transaction sent to a P2WSH address is this one: 461e8a4aa0a0e75c06602c505bd7aa06e7116ba5cd98fd6e046e8cbeb00379d6 It occurred in ...
Tom's user avatar
  • 43
1 vote
Accepted

Using multiple penalty transactions to increase max HTLCs per LN channel

Are there any significant hurdles preventing us from using multiple penalty transactions, where the nth penalty transaction spends HTLCs [n*483; (n+1)*483[ from the commitment transaction? At first ...
David A. Harding's user avatar
1 vote
Accepted

Is the dust output limit the same for p2wpkh and p2wsh?

I just realized that there are in fact these two lines which takes into account the size of CTxOut: size_t nSize = GetSerializeSize(txout); ... ... nSize += (32 + 4 + 1 + (107 / WITNESS_SCALE_FACTOR) ...
Darius's user avatar
  • 789
1 vote

Generate P2SH-P2WSH

At the time this question was asked, this issue was the result of a bug in Bitcoin Core. It was fixed in PR #18484 and is available in Bitcoin Core 0.20+.
Ava Chow's user avatar
  • 70.4k

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