Skip to content

Commit b025aa3

Browse files
committed
Merge #15846: [POLICY] Make sending to future native witness outputs standard
c634b1e [POLICY] Make sending to future native witness outputs standard (Pieter Wuille) Pull request description: As discussed in the April 18 2019 IRC meeting. This makes sending to future Segwit versions via native outputs (bech32) standard for relay, mempool acceptance, and mining. The reasons are: * This may interfere with smooth adoption of future segwit versions, if they're defined (by the sender wallet/node). * It violates BIP173 ("Version 0 witness addresses are always 42 or 62 characters, but implementations MUST allow the use of any version."), though admittedly this code was written before BIP173. * It doesn't protect much, as P2SH-embedded segwit cannot be filtered in this way. * As a general policy, the sender shouldn't care what the receiver likes his outputs to be. Note that _spending_ such outputs (including P2SH-embedded ones) remains nonstandard, as that is actually required for softfork safety. ACKs for commit c634b1: MarcoFalke: utACK c634b1e harding: Tested ACK c634b1e meshcollider: utACK bitcoin/bitcoin@c634b1e Tree-SHA512: e37168a1be9f445a04d4280593f0a92bdae33eee00ecd803d5eb16acb5c9cfc0f1f0a1dfbd5a0cc73da2c9928ec11cbdac7911513a78f85b789ae0d00e1b5962
2 parents 7034149 + c634b1e commit b025aa3

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/policy/policy.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType)
5959
std::vector<std::vector<unsigned char> > vSolutions;
6060
whichType = Solver(scriptPubKey, vSolutions);
6161

62-
if (whichType == TX_NONSTANDARD || whichType == TX_WITNESS_UNKNOWN) {
62+
if (whichType == TX_NONSTANDARD) {
6363
return false;
6464
} else if (whichType == TX_MULTISIG) {
6565
unsigned char m = vSolutions.front()[0];

test/functional/p2p_segwit.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,7 +1360,8 @@ def test_tx_relay_after_segwit_activation(self):
13601360
def test_segwit_versions(self):
13611361
"""Test validity of future segwit version transactions.
13621362
1363-
Future segwit version transactions are non-standard, but valid in blocks.
1363+
Future segwit versions are non-standard to spend, but valid in blocks.
1364+
Sending to future segwit versions is always allowed.
13641365
Can run this before and after segwit activation."""
13651366

13661367
NUM_SEGWIT_VERSIONS = 17 # will test OP_0, OP1, ..., OP_16
@@ -1400,18 +1401,17 @@ def test_segwit_versions(self):
14001401
assert len(self.nodes[0].getrawmempool()) == 0
14011402

14021403
# Finally, verify that version 0 -> version 1 transactions
1403-
# are non-standard
1404+
# are standard
14041405
script_pubkey = CScript([CScriptOp(OP_1), witness_hash])
14051406
tx2 = CTransaction()
14061407
tx2.vin = [CTxIn(COutPoint(tx.sha256, 0), b"")]
14071408
tx2.vout = [CTxOut(tx.vout[0].nValue - 1000, script_pubkey)]
14081409
tx2.wit.vtxinwit.append(CTxInWitness())
14091410
tx2.wit.vtxinwit[0].scriptWitness.stack = [witness_program]
14101411
tx2.rehash()
1411-
# Gets accepted to test_node, because standardness of outputs isn't
1412-
# checked with fRequireStandard
1412+
# Gets accepted to both policy-enforcing nodes and others.
14131413
test_transaction_acceptance(self.nodes[0], self.test_node, tx2, with_witness=True, accepted=True)
1414-
test_transaction_acceptance(self.nodes[1], self.std_node, tx2, with_witness=True, accepted=False)
1414+
test_transaction_acceptance(self.nodes[1], self.std_node, tx2, with_witness=True, accepted=True)
14151415
temp_utxo.pop() # last entry in temp_utxo was the output we just spent
14161416
temp_utxo.append(UTXO(tx2.sha256, 0, tx2.vout[0].nValue))
14171417

0 commit comments

Comments
 (0)