Return-Path: Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id E49BD13F1 for ; Sun, 26 May 2019 16:18:48 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id F3F476C5 for ; Sun, 26 May 2019 16:18:47 +0000 (UTC) Received: by mail-wr1-f45.google.com with SMTP id l2so14479046wrb.9 for ; Sun, 26 May 2019 09:18:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:openpgp:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=AXteIk6D/scS0YS31Q3vtlquBw2DJEMW324fzhWjBgc=; b=qhhgnVPYhpG+FQcu8v1QK+KcUuWp9jn+lsRIkdUwxA5hMO3Av7R99WG1pd/9HPGbe1 r9EfCPzDPD4Q3tn057cpn3ddubZyquXGKAnIBHjgyPMp51T2gSuEi9Q2Y763NFTSgH3o DTR91CvUZEsWt8d2tjrrIdSb4CIayXEdx1OW1ti0rj36k1z8LeoolcX+fmEMsibC2nUJ n/Km373niI44/OIhGGPXf3eqSRYNM4+HGHaMc3v31Ww6/L/HUazSxn2sYIXxPMrrTV9J XRtjbPly3KTpj+iqmgXFxAhukK6xX8BE47loUHrOgd8FNeID2FNQgN80004kImHLIdps N1bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:openpgp:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-transfer-encoding:content-language; bh=AXteIk6D/scS0YS31Q3vtlquBw2DJEMW324fzhWjBgc=; b=gYrKIqSWXOzgHBIjbn7OXzOCtVdExgqWrO/3qa0F56N62cG+pSePQyxMA1PQPUGzwS tVA1GaGDpLX8LvSLrXhAJ2zs4ImUUkrpxb1w2eVfAN7np8PJIDKwjT7TBmeqEYCITgjq nMrumg1q7BgPXJNlZTpVbRbIb+L+uPK/d67mVmDtZj1gp8+NbqIXGtq23tL1rkEIkr3v nhd2N1qeoxVxYIjOCQU8pc241JiDQlSL5WiVndupTqX5Za5vA4KSwlwkqt1SnER8ymGm E1sNFHJSY2ItrnbitONjJO8+P2EzvWkbOV3bINYuLd4rmT/mJfSuk8CwjqZDx3onzTZ+ NnIQ== X-Gm-Message-State: APjAAAUEIBtIyrpMmMc1zm1KFeDgRBVzzfCSqTK5xthNvYqJrdKYk487 tEGA2iaDfIkTfuIgfDzMso1C4GQJ X-Google-Smtp-Source: APXvYqxwmva6cECF8Wpavvturtv/LWXdSyUa7L/nKhky5aFozo66nXD72+BkZdqdsRdkgNccY70u4w== X-Received: by 2002:adf:c98f:: with SMTP id f15mr22085467wrh.279.1558887526304; Sun, 26 May 2019 09:18:46 -0700 (PDT) Received: from ?IPv6:2a01:cb1d:44:6500:9d6d:71b2:cb71:cb17? ([2a01:cb1d:44:6500:9d6d:71b2:cb71:cb17]) by smtp.googlemail.com with ESMTPSA id p11sm6909062wrs.5.2019.05.26.09.18.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 May 2019 09:18:45 -0700 (PDT) To: Johnson Lau , bitcoin-dev References: <6DFB6C65-D123-40FD-9CE3-49FFCA81EE46@xbt.hk> From: Aymeric Vitte Openpgp: preference=signencrypt Autocrypt: addr=vitteaymeric@gmail.com; prefer-encrypt=mutual; keydata= mQINBFdW8uABEAC7HJScbB2d/lmYoY5Cn9loEjJwfLs1LC3om030bWFGiH3Ceo5XeHUT94rw Pi+HaHU8ea94425SXIFsnqp/ouoT/8Ffn6vED0OoRmK0jE4fqDApXSpoL2mHX9PAGdUItMtD YrxBiBZNfMkctEsm4NrQ4TCvB3Yrm6Fc69inXJjUoYgPw5tHafEeI8Qwh0j99JZZDKcAqIra JF3M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utfFNO3Gwc q31QW3n3LJHnpqdrV3WsRzT5NwJMVtiIAGRrX8ZomtarWHT0PeEHC2xBdFzRrJtmkrwer0Wc 0nBzD7vk1XEXC9nODbmlgsesoHFgRwQBst3wClCbX1gv8aSfxQNpaf9UBC8DmyrQ621UXpBo PvcFEtWxV44vJfP0WOLCCN0Pzv2F2I66iKo7VMqbr5jlNAXJN9I1hXb7qwYJmBC9j5oeEoqv A9d44WWpxrdAr8qih4Nv89k9+9F6NoqORY3FGuVDKiW8CVhCmGT7bIvNeyicVBZFipXqPcKL VFduO2c5Ubc2npMWLUF1k9JJc9tH75l3+F/0RbYVTzGAZ+zSaudwR6h8YiCN2DBZGZkJEZbh 3X/l6jtijMN/W9sPHyyKvm/TmeEC27S3TqZPZ8PUQLxZC70V6gMbenh01JdSQsn5t8Ru0RNh Blt0g7IyZyIKCE9b+TyzbYpX6qgqEBUHia5b0vyPtQacWQlZ8uqnghAqNkLluEsy7Q/7xG6M wXUYEDsFOmB9dKOzcAOIhpxlVjSKu5mzXJ11sEtE8nyF5NJ/riCA7FGcjlki3zIpzQUNo9v7 vXl2h6Tivlk= Message-ID: Date: Sun, 26 May 2019 18:18:46 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.3; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <6DFB6C65-D123-40FD-9CE3-49FFCA81EE46@xbt.hk> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: fr X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org X-Mailman-Approved-At: Mon, 27 May 2019 14:28:11 +0000 Subject: Re: [bitcoin-dev] Two questions about segwit implementation X-BeenThere: bitcoin-dev@lists.linuxfoundation.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Bitcoin Protocol Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 26 May 2019 16:18:49 -0000 OK, thanks, understood for OP_0 but still for the 00 number of witness data for non segwit inputs the one that is doing the transaction knows which inputs are segwit or not, then parsing the transaction you can associate the correct input to the correct witness data, without the need of 00, so I must be missing the use case Le 26/05/2019 à 16:33, Johnson Lau a écrit : >> On 26 May 2019, at 7:56 AM, Aymeric Vitte via bitcoin-dev wrote: >> >> I realized recently that my segwit implementation was not correct, >> basically some time ago, wrongly reading the specs (and misleaded by >> what follows), I thought that scriptsig would go into witness data as it >> was, but that's not the case, op_pushdata is replaced by varlen >> > Witness is not script. There is no op_pushdata or any other opcodes. > > Witness is a stack. For each input, the witness starts with a CCompactSize for the number of stack elements for this input. Each stack element in turns starts with a CCompactSize for the size of this element, followed by the actual data > > >> Now reading correctly the specs, they seem to be not totally correct, >> then the first question is: why OP_0 is 00 in witness data and not 0100? >> Does this apply to other op_codes? This does not look logical at all >> > A “00” element means the size of this element is zero. Since it’s zero size, no data is followed. This will create an empty element on the stack. It’s effectively same as OP_0 (Again, witness is not script) > > A “0100” element means the element size is one, and the data for this element is “00”. So it will leave an 1-byte element on the stack. > > >> The second question is: why for non segwit inputs there is a 00 length >> in segwit data, what is the rational for that? It should just be nothing >> since you don't need this to reconciliate things > The “00” here means "this input has no witness stack element”. You need this even for non segwit inputs, because there is no way to tell whether an input is segwit-enabled or not, until you look up the UTXO, which might not be always available. Transaction serialization couldn’t rely on contextual information. > > However, if all inputs have no stack element, the spec requires you to always use the non-segwit serialization. > >> _______________________________________________ >> bitcoin-dev mailing list >> bitcoin-dev@lists.linuxfoundation.org >> https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev > -- Move your coins by yourself (browser version): https://peersm.com/wallet Bitcoin transactions made simple: https://github.com/Ayms/bitcoin-transactions Zcash wallets made simple: https://github.com/Ayms/zcash-wallets Bitcoin wallets made simple: https://github.com/Ayms/bitcoin-wallets Get the torrent dynamic blocklist: http://peersm.com/getblocklist Check the 10 M passwords list: http://peersm.com/findmyass Anti-spies and private torrents, dynamic blocklist: http://torrent-live.org Peersm : http://www.peersm.com torrent-live: https://github.com/Ayms/torrent-live node-Tor : https://www.github.com/Ayms/node-Tor GitHub : https://www.github.com/Ayms