From a516c135ab622dcf0a4ecf204476034cb086d287 Mon Sep 17 00:00:00 2001
From: Anthony Towns <aj@erisian.com.au>
Date: Thu, 25 Mar 2021 15:36:51 +1000
Subject: BIP341/342: document current deployment status

---
 bip-0341.mediawiki | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

(limited to 'bip-0341.mediawiki')

diff --git a/bip-0341.mediawiki b/bip-0341.mediawiki
index 0f8d32a..1e579e1 100644
--- a/bip-0341.mediawiki
+++ b/bip-0341.mediawiki
@@ -294,7 +294,9 @@ Examples of preimage for sighashing for each of the sighash modes.
 
 == Deployment ==
 
-TODO
+This BIP is deployed concurrently with [[bip-0342.mediawiki|BIP342]].
+
+For Bitcoin signet, these BIPs are always active.
 
 == Backwards compatibility ==
 As a soft fork, older software will continue to operate without modification.
-- 
cgit v1.2.3


From 0f95720639c743df2546730a5549eb7ead610529 Mon Sep 17 00:00:00 2001
From: Anthony Towns <aj@erisian.com.au>
Date: Wed, 24 Mar 2021 20:35:24 +1000
Subject: BIP341: bip9 speedy trial parameters

---
 bip-0341.mediawiki | 10 ++++++++++
 1 file changed, 10 insertions(+)

(limited to 'bip-0341.mediawiki')

diff --git a/bip-0341.mediawiki b/bip-0341.mediawiki
index 1e579e1..c464b59 100644
--- a/bip-0341.mediawiki
+++ b/bip-0341.mediawiki
@@ -298,6 +298,16 @@ This BIP is deployed concurrently with [[bip-0342.mediawiki|BIP342]].
 
 For Bitcoin signet, these BIPs are always active.
 
+For Bitcoin mainnet, these BIPs will be deployed by "version bits" with the name "taproot" and bit 2, using BIP9 modified to use a lower threshold, and with an additional ''min_activation_height'' parameter and changing the state transition logic for LOCKED_IN to the following:
+
+    case LOCKED_IN:
+        if (block.nHeight < min_activation_height) {
+            return LOCKED_IN;
+        }
+        return ACTIVE;
+
+For Bitcoin mainnet, the BIP9 starttime is epoch timestamp 1619222400 (midnight 24 April 2021 UTC), BIP9 timeout is epoch timestamp 1628640000 (midnight 11 August 2021 UTC), the threshold is 1815 blocks (90%) instead of 1916 blocks (95%), and the min_activation_height is block 709632 (expected approximately 12 November 2021).
+
 == Backwards compatibility ==
 As a soft fork, older software will continue to operate without modification.
 Non-upgraded nodes, however, will consider all SegWit version 1 witness programs as anyone-can-spend scripts.
-- 
cgit v1.2.3


From d582d0bd3162ac7a3f6f1aae46daf7eeb24b201e Mon Sep 17 00:00:00 2001
From: Anthony Towns <aj@erisian.com.au>
Date: Thu, 8 Apr 2021 18:30:51 +1000
Subject: BIP341: document simplified bip9 states

---
 bip-0341.mediawiki | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

(limited to 'bip-0341.mediawiki')

diff --git a/bip-0341.mediawiki b/bip-0341.mediawiki
index c464b59..ec26250 100644
--- a/bip-0341.mediawiki
+++ b/bip-0341.mediawiki
@@ -298,7 +298,29 @@ This BIP is deployed concurrently with [[bip-0342.mediawiki|BIP342]].
 
 For Bitcoin signet, these BIPs are always active.
 
-For Bitcoin mainnet, these BIPs will be deployed by "version bits" with the name "taproot" and bit 2, using BIP9 modified to use a lower threshold, and with an additional ''min_activation_height'' parameter and changing the state transition logic for LOCKED_IN to the following:
+For Bitcoin mainnet, these BIPs will be deployed by "version bits" with the name "taproot" and bit 2, using [[bip-0009.mediawiki|BIP9]] modified to use a lower threshold, with an additional ''min_activation_height'' parameter and replacing the state transition logic for the DEFINED, STARTED and LOCKED_IN states as follows:
+
+    case DEFINED:
+        if (GetMedianTimePast(block.parent) >= starttime) {
+            return STARTED;
+        }
+        return DEFINED;
+
+    case STARTED:
+        int count = 0;
+        walk = block;
+        for (i = 0; i < 2016; i++) {
+            walk = walk.parent;
+            if (walk.nVersion & 0xE0000000 == 0x20000000 && (walk.nVersion >> bit) & 1 == 1) {
+                count++;
+            }
+        }
+        if (count >= threshold) {
+            return LOCKED_IN;
+        } else if (GetMedianTimePast(block.parent) >= timeout) {
+            return FAILED;
+        }
+        return STARTED;
 
     case LOCKED_IN:
         if (block.nHeight < min_activation_height) {
@@ -306,7 +328,7 @@ For Bitcoin mainnet, these BIPs will be deployed by "version bits" with the name
         }
         return ACTIVE;
 
-For Bitcoin mainnet, the BIP9 starttime is epoch timestamp 1619222400 (midnight 24 April 2021 UTC), BIP9 timeout is epoch timestamp 1628640000 (midnight 11 August 2021 UTC), the threshold is 1815 blocks (90%) instead of 1916 blocks (95%), and the min_activation_height is block 709632 (expected approximately 12 November 2021).
+For Bitcoin mainnet, the starttime is epoch timestamp 1619222400 (midnight 24 April 2021 UTC), timeout is epoch timestamp 1628640000 (midnight 11 August 2021 UTC), the threshold is 1815 blocks (90%) instead of 1916 blocks (95%), and the min_activation_height is block 709632 (expected approximately 12 November 2021).
 
 == Backwards compatibility ==
 As a soft fork, older software will continue to operate without modification.
-- 
cgit v1.2.3


From ce5f89fe0ddd99a00bcd1457df407cccd60a9336 Mon Sep 17 00:00:00 2001
From: Anthony Towns <aj@erisian.com.au>
Date: Thu, 8 Apr 2021 18:31:04 +1000
Subject: BIP341: add testnet3 parameters

---
 bip-0341.mediawiki | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

(limited to 'bip-0341.mediawiki')

diff --git a/bip-0341.mediawiki b/bip-0341.mediawiki
index ec26250..f682d96 100644
--- a/bip-0341.mediawiki
+++ b/bip-0341.mediawiki
@@ -298,7 +298,7 @@ This BIP is deployed concurrently with [[bip-0342.mediawiki|BIP342]].
 
 For Bitcoin signet, these BIPs are always active.
 
-For Bitcoin mainnet, these BIPs will be deployed by "version bits" with the name "taproot" and bit 2, using [[bip-0009.mediawiki|BIP9]] modified to use a lower threshold, with an additional ''min_activation_height'' parameter and replacing the state transition logic for the DEFINED, STARTED and LOCKED_IN states as follows:
+For Bitcoin mainnet and testnet3, these BIPs will be deployed by "version bits" with the name "taproot" and bit 2, using [[bip-0009.mediawiki|BIP9]] modified to use a lower threshold, with an additional ''min_activation_height'' parameter and replacing the state transition logic for the DEFINED, STARTED and LOCKED_IN states as follows:
 
     case DEFINED:
         if (GetMedianTimePast(block.parent) >= starttime) {
@@ -330,6 +330,8 @@ For Bitcoin mainnet, these BIPs will be deployed by "version bits" with the name
 
 For Bitcoin mainnet, the starttime is epoch timestamp 1619222400 (midnight 24 April 2021 UTC), timeout is epoch timestamp 1628640000 (midnight 11 August 2021 UTC), the threshold is 1815 blocks (90%) instead of 1916 blocks (95%), and the min_activation_height is block 709632 (expected approximately 12 November 2021).
 
+For Bitcoin testnet3, the starttime is epoch timestamp 1619222400 (midnight 24 April 2021 UTC), timeout is epoch timestamp 1628640000 (midnight 11 August 2021 UTC), the threshold is 1512 blocks (75%), and the min_activation_height is block 0.
+
 == Backwards compatibility ==
 As a soft fork, older software will continue to operate without modification.
 Non-upgraded nodes, however, will consider all SegWit version 1 witness programs as anyone-can-spend scripts.
-- 
cgit v1.2.3


From 43b5f171dcf2b3cd8a2f1b0a71f0dfe31946f46a Mon Sep 17 00:00:00 2001
From: Jonas Nick <jonasd.nick@gmail.com>
Date: Tue, 13 Apr 2021 14:52:44 +0000
Subject: BIP 341/342: Add link to Bitcoin Core test vectors

Also remove mention of non-existing examples.
---
 bip-0341.mediawiki | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

(limited to 'bip-0341.mediawiki')

diff --git a/bip-0341.mediawiki b/bip-0341.mediawiki
index 0f8d32a..a1c45cc 100644
--- a/bip-0341.mediawiki
+++ b/bip-0341.mediawiki
@@ -284,9 +284,7 @@ The reason for this is to increase leaf entropy and prevent an observer from lea
 
 == Test vectors ==
 
-Examples with creation transaction and spending transaction pairs, valid and invalid.
-
-Examples of preimage for sighashing for each of the sighash modes.
+The test vectors used in the [https://github.com/bitcoin/bitcoin/blob/3820090bd619ac85ab35eff376c03136fe4a9f04/src/test/script_tests.cpp#L1718 Bitcoin Core unit test framework] can be found [https://github.com/bitcoin-core/qa-assets/blob/main/unit_test_data/script_assets_test.json?raw=true here].
 
 == Rationale ==
 
-- 
cgit v1.2.3


From 93d1b1528592ca129109b4630c17fa5372e4048a Mon Sep 17 00:00:00 2001
From: Anthony Towns <aj@erisian.com.au>
Date: Tue, 13 Apr 2021 10:45:02 +1000
Subject: BIP341: add brackets to avoid ambiguity due to precendence rules
 around bipwise ops

---
 bip-0341.mediawiki | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'bip-0341.mediawiki')

diff --git a/bip-0341.mediawiki b/bip-0341.mediawiki
index f682d96..5450a08 100644
--- a/bip-0341.mediawiki
+++ b/bip-0341.mediawiki
@@ -311,7 +311,7 @@ For Bitcoin mainnet and testnet3, these BIPs will be deployed by "version bits"
         walk = block;
         for (i = 0; i < 2016; i++) {
             walk = walk.parent;
-            if (walk.nVersion & 0xE0000000 == 0x20000000 && (walk.nVersion >> bit) & 1 == 1) {
+            if ((walk.nVersion & 0xE0000000) == 0x20000000 && ((walk.nVersion >> bit) & 1) == 1) {
                 count++;
             }
         }
-- 
cgit v1.2.3

