Return-Path: Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 5AD60CFB for ; Thu, 5 Jul 2018 19:20:34 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from jb55.com (jb55.com [45.79.91.128]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 1002976E for ; Thu, 5 Jul 2018 19:20:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d= jb55.com; h=from:to:subject:date:message-id; s=default; bh=iX0oYbNngTbatJ6+NDdCPLEzaIxOGBUak5p9NpdMpa4=; b=isN1Z0cMeoi4Wr0rlY74PbWuQcXY10jGEmaParL7/5U2jOIwtrXdvkr3W4sKALZ243UXOT0Fy5vdpu/JDVbC6NHOrIWQp1oFDlMio58mugjfyADYmI1FFFRfb8sp6+0zZSun+oWktz8zWEXs+vVBJPyCqSAscihiGXfxnVjm8w0KMRSkRq0wPjIvMRaHAn9uDlUTx/6yhbHOqAyCqT9RLn03539inAI3NGa5VPAz73iGkoMIegFCvwE69kdnaxBUBXqot0AkvTdc9CbfZI/NvRkahSaYclQCRXxDt3h540PCMTMtpiwIlKpW9Pj3gI3pOcu5mK3yGqwt++xMterhzA== Received: from jb55.com (S0106f0f24985f313.gv.shawcable.net [24.69.17.186]) by jb55.com (OpenSMTPD) with ESMTPSA id 3ecc9e34 TLS version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO; Thu, 5 Jul 2018 19:20:33 +0000 (UTC) From: William Casarin To: Achow101 In-Reply-To: <0BT4A0BFbcfUM9xlYjS-7Cy1zpaI1J9qsIpWH_xgv2ZLhcmxb4Es5KlpMJCvHVEu8BDbBweZ92RHnES5HxDMulRhJkYSZAPi-CgXQ3uwkfY=@achow101.com> References: <21a616f5-7a17-35b9-85ea-f779f20a6a2d@satoshilabs.com> <20180621195654.GC99379@coinkite.com> <87k1qk7oca.fsf@jb55.com> Date: Thu, 05 Jul 2018 12:20:32 -0700 Message-ID: <87in5ttrpb.fsf@jb55.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU 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: Fri, 06 Jul 2018 18:31:18 +0000 Cc: Bitcoin Protocol Discussion Subject: Re: [bitcoin-dev] BIP 174 thoughts 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: Thu, 05 Jul 2018 19:20:34 -0000 I have another concern with the format. (my original bip comment for some context: [1]) It looks like the one of the reasons I was confused is because you can only parse the format properly by first deserializing the transaction. Since there is no "length" field for the key-value map arrays, you must count the number of transaction input/outputs, and use that as the number of kv maps to parse. This is pretty brittle, because now if a Combiner writes the wrong number of key-value maps that don't align with the number of inputs and outputs in the transaction, then the psbt will not be able to be deserialized properly, but is still a valid PSBT. It can't even detect these situations, because the input and output types share the same enum values. I don't see anywhere that says the number of key value maps MUST match the number of inputs/outputs, perhaps it's implied? I think I think we should either make this explicit in the BIP, add an array length prefix, or make all (global/input/output) types share the same enum. Cheers, William [1] https://github.com/bitcoin/bips/pull/694#issuecomment-402812041