summaryrefslogtreecommitdiff
path: root/2d/583b489ed5b557c9aa5240ba81d299857832ae
blob: e34d78df1b72b9600a402728b603423f15d5d190 (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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
Return-Path: <vitteaymeric@gmail.com>
Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org
	[172.17.192.35])
	by mail.linuxfoundation.org (Postfix) with ESMTPS id E49BD13F1
	for <bitcoin-dev@lists.linuxfoundation.org>;
	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 <bitcoin-dev@lists.linuxfoundation.org>;
	Sun, 26 May 2019 16:18:47 +0000 (UTC)
Received: by mail-wr1-f45.google.com with SMTP id l2so14479046wrb.9
	for <bitcoin-dev@lists.linuxfoundation.org>;
	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 <jl2012@xbt.hk>,
	bitcoin-dev <bitcoin-dev@lists.linuxfoundation.org>
References: <e537e781-e10f-7299-fddb-67fab74124c0@gmail.com>
	<6DFB6C65-D123-40FD-9CE3-49FFCA81EE46@xbt.hk>
From: Aymeric Vitte <vitteaymeric@gmail.com>
Openpgp: preference=signencrypt
Autocrypt: addr=vitteaymeric@gmail.com; prefer-encrypt=mutual; keydata=
	mQINBFdW8uABEAC7HJScbB2d/lmYoY5Cn9loEjJwfLs1LC3om030bWFGiH3Ceo5XeHUT94rw
	Pi+HaHU8ea94425SXIFsnqp/ouoT/8Ffn6vED0OoRmK0jE4fqDApXSpoL2mHX9PAGdUItMtD
	YrxBiBZNfMkctEsm4NrQ4TCvB3Yrm6Fc69inXJjUoYgPw5tHafEeI8Qwh0j99JZZDKcAqIra
	JF3MPc59rATz0qOJtRP9EpsPVFwjJe13zN6CHILwiVgrL8EtT5WKCVO6ATxh60LHi8+MwPxV
	V31zp/NNI5Hck+XocEMO98ZvUu9X8ZxmnOk/+9pBxXEwUqSGUNWdmPJLncpI23Usce3u/MOo
	M2C4T4rD4J0XrXiyBvbeTvwq4qVNlyggeWzlBH+YpEYgDctPq4gNh4eoTtAkf8URtBeke5bQ
	CGdaZt/jxv8nvmxs9V/iSyg5ldJLQktHStXOo0OZ7FEB2C6Ggtymm4hm2MHYg07Q1MGJrFLa
	oJZkJ3JeXnVsZMam7ypQtld6rRa96CvH+llXwux6aQ5hKdzmBBMQ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IvNeyicVBZFipXqPcKL
	VFduO2c5Ubc2npMWLUF1k9JJc9tH75l3+F/0RbYVTzGAZ+zSaudwR6h8YiCN2DBZGZkJEZbh
	3X/l6jtijMN/W9sPHyyKvm/TmeEC27S3TqZPZ8PUQLxZC70V6gMbenh01JdSQsn5t8Ru0RNh
	Blt0g7IyZyIKCE9b+TyzbYpX6qgqEBUHia5b0vyPtQacWQlZ8uqnghAqNkLluEsy7Q/7xG6M
	wXUYEDsFOmB9dKOzcAOIhpxlVjSKu5mzXJ11sEtE8nyF5NJ/riCA7FGcjlki3zIpzQUNo9v7
	vXl2h6Tivlk=
Message-ID: <e342cb8f-a909-a806-bd76-91580234cd7f@gmail.com>
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 <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: 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 <bitcoin-dev@lists.linuxfoundation.org> 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