summaryrefslogtreecommitdiff
path: root/2d/e0ed5de087cc9080f60c248b216d57e40cd412
blob: 29424758f670f88a5fa1b08a363fda3b0ca4ac84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
Return-Path: <symphonicbtc@proton.me>
Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133])
 by lists.linuxfoundation.org (Postfix) with ESMTP id 923DCC0032
 for <bitcoin-dev@lists.linuxfoundation.org>;
 Fri, 11 Aug 2023 07:38:46 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by smtp2.osuosl.org (Postfix) with ESMTP id E1BFD40116
 for <bitcoin-dev@lists.linuxfoundation.org>;
 Fri, 11 Aug 2023 07:38:45 +0000 (UTC)
DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org E1BFD40116
Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key,
 unprotected) header.d=proton.me header.i=@proton.me header.a=rsa-sha256
 header.s=protonmail header.b=SI0Qy/Uc
X-Virus-Scanned: amavisd-new at osuosl.org
X-Spam-Flag: NO
X-Spam-Score: -2.102
X-Spam-Level: 
X-Spam-Status: No, score=-2.102 tagged_above=-999 required=5
 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
 DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001,
 SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Received: from smtp2.osuosl.org ([127.0.0.1])
 by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id udn67pRNNN4C
 for <bitcoin-dev@lists.linuxfoundation.org>;
 Fri, 11 Aug 2023 07:38:45 +0000 (UTC)
Received: from mail-41103.protonmail.ch (mail-41103.protonmail.ch
 [185.70.41.103])
 by smtp2.osuosl.org (Postfix) with ESMTPS id 7E180400D1
 for <bitcoin-dev@lists.linuxfoundation.org>;
 Fri, 11 Aug 2023 07:38:43 +0000 (UTC)
DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 7E180400D1
Date: Fri, 11 Aug 2023 07:38:13 +0000
Authentication-Results: mail-41103.protonmail.ch;
 dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me
 header.b="SI0Qy/Uc"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me;
 s=protonmail; t=1691739511; x=1691998711;
 bh=j6HWFvyA9Sh6wWj8IPrYuOG2w8ZksHD0vHeG7UZ2Kp4=;
 h=Date:To:From:Subject:Message-ID:In-Reply-To:References:
 Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:
 Message-ID:BIMI-Selector;
 b=SI0Qy/Uckaf0+rAophsHKkavq0AH2sQx+0A7JwGyoM8suyZlOuMTbXu0y5BbHUXla
 ETX+sgpSKS70SuEidh1R7HlW1jvTVYht+e19Jyl7xyFWiasnibFXoiDaNpQTLefa0a
 P2golsXU3PG9AaG/58jeNG1H1dK5HTSnfWy2XbIcU7oZ4XW0dmRuJLWENdV8pBW0bW
 K+7atxKbC/rQ21hrXaoDtAYosbsitFWRDfxGLTs4zLyEIapqJM2xY3o8MynCURFEUZ
 hdPb58c3/DwTDtNRTthA2QKwM9cNgDlIRbiEm4QcxHusoJPBrx6xgCWRUex/nfwN2y
 1iqwSXFbwE+Xg==
To: Tobin Harding <me@tobin.cc>, "bitcoin-dev@lists.linuxfoundation.org"
 <bitcoin-dev@lists.linuxfoundation.org>
From: symphonicbtc <symphonicbtc@proton.me>
Message-ID: <XuIlG8ZnGSikbG0DQ34BAQE_k7bTBoO_YgeAVuynutat-0pQuSF0GfdpvUApGH94g66zXtkgEguy0NnxxnGuBzm-7PA1U40cIa9UsEI8_Yg=@proton.me>
In-Reply-To: <ZNW9BenWIhgX95zl@alke>
References: <ZNW9BenWIhgX95zl@alke>
Feedback-ID: 77757318:user:proton
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Mailman-Approved-At: Fri, 11 Aug 2023 09:58:52 +0000
Subject: Re: [bitcoin-dev] segwit naming ambiguity
X-BeenThere: bitcoin-dev@lists.linuxfoundation.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: Bitcoin Protocol Discussion <bitcoin-dev.lists.linuxfoundation.org>
List-Unsubscribe: <https://lists.linuxfoundation.org/mailman/options/bitcoin-dev>, 
 <mailto:bitcoin-dev-request@lists.linuxfoundation.org?subject=unsubscribe>
List-Archive: <http://lists.linuxfoundation.org/pipermail/bitcoin-dev/>
List-Post: <mailto:bitcoin-dev@lists.linuxfoundation.org>
List-Help: <mailto:bitcoin-dev-request@lists.linuxfoundation.org?subject=help>
List-Subscribe: <https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev>, 
 <mailto:bitcoin-dev-request@lists.linuxfoundation.org?subject=subscribe>
X-List-Received-Date: Fri, 11 Aug 2023 07:38:46 -0000

Transactions should be considered segwit if they match the witness program =
structure of "A scriptPubKey (or redeemScript as defined in BIP16/P2SH) tha=
t consists of a 1-byte push opcode (for 0 to 16) followed by a data push be=
tween 2 and 40 bytes" as defined in [BIP141](https://github.com/bitcoin/bip=
s/blob/master/bip-0141.mediawiki#witness-program). This would return true f=
or version 0 segwit outputs as well as version 1 taproot outputs.

I would propose a different function for differentiating v0 vs taproot scri=
pts. Bitcoin core uses an [enum](https://github.com/bitcoin/bitcoin/blob/ma=
ster/src/script/standard.h#L51), of which you can use something similar. Co=
re also uses a different [enum](https://github.com/bitcoin/bitcoin/blob/mas=
ter/src/outputtype.h) for wallet logic, but it has a highly confusing namin=
g scheme which imo should be avoided.

Additionally, witness programs nested inside P2SH need to be considered. Th=
e context in which these are interpreted depends on whether or not they sho=
uld be differentiated from other P2SH, as is shown with the 2 separate enum=
s from core. It is possible that this would cause some ambiguity, and it sh=
ould be explicitly documented how such functions would return for different=
 types of programs. These nested programs should technically also be consid=
ered segwit for a simple `is_segwit`, as they have segregated witness data.

v0 is the most common way of referring to version 0 segwit.

Symphonic


------- Original Message -------
On Friday, August 11th, 2023 at 4:45 AM, Tobin Harding via bitcoin-dev bitc=
oin-dev@lists.linuxfoundation.org wrote:

> Question for OG bitcoin API designers please.
>
> If you were to see the following function
>
> `is_segwit()`
>
> would you assume it returns `true` or `false` for a p2tr transaction?
>
> Currently we (rust-bitcoin) are being liberal with the use of `v0` but
> its a pretty ugly. Is there an official, or widely used, name for segwit =
v0?
>
> Thanks,
> Tobin.
> _______________________________________________
> bitcoin-dev mailing list
> bitcoin-dev@lists.linuxfoundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev