Return-Path: Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 923DCC0032 for ; 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 ; 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 ; 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 ; 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 , "bitcoin-dev@lists.linuxfoundation.org" From: symphonicbtc Message-ID: In-Reply-To: References: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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