From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 98E1CC013A for ; Thu, 21 Jan 2021 19:51:10 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 5E3D927236 for ; Thu, 21 Jan 2021 19:51:10 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hgizausa1XFl for ; Thu, 21 Jan 2021 19:51:06 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-41104.protonmail.ch (mail-41104.protonmail.ch [185.70.41.104]) by silver.osuosl.org (Postfix) with ESMTPS id CC3A1271D6 for ; Thu, 21 Jan 2021 19:51:05 +0000 (UTC) Received: from mail-03.mail-europe.com (mail-03.mail-europe.com [91.134.188.129]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by mail-41104.protonmail.ch (Postfix) with ESMTPS id C242B2000FAA for ; Thu, 21 Jan 2021 19:51:03 +0000 (UTC) Authentication-Results: mail-41104.protonmail.ch; dkim=pass (2048-bit key) header.d=achow101.com header.i=@achow101.com header.b="va/CPtZe" Date: Thu, 21 Jan 2021 19:50:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=achow101.com; s=protonmail3; t=1611258651; bh=niDPnXVQRlIQf7k8nTXmiuY2IiOKb8ltZ05ov4jBItE=; h=Date:To:From:Reply-To:Subject:In-Reply-To:References:From; b=va/CPtZeQsobusOo07sDGbFUn1GXhgM2roV8P6WPgkPE7604MN7lW7KCReFEa0dnY afDAwF/a5lwpHvpDaZOxQlTtKWL84aEioQGGByiPZD6o6Efg4dKpeeOGO5TtAu0ZIQ WKz2NcZ1g5I7p2IVUOUt4+nqsUqdcS9oIYx1lDej9bNrRLKW0NOhhNAG/khxwTV0OY idTPThSKMDmyBf5B77VVB8WR+qdR17XnVNY8c1kLGc9Z7X+oAhuSMHuzLPobqB/GsP JWK6AvS2BAy6/L5h2+f2QU9JsD9IrjVQV0j0nWD2FgMUx/VYZEIXc/NGdQYaXvMTZB 7IM3ttWfBZKHw== To: Bitcoin Protocol Discussion From: Andrew Chow Reply-To: Andrew Chow Message-ID: <16f16c05-c3b3-57c2-5070-9e70c1823b40@achow101.com> In-Reply-To: References: <1dd8c285-e3f4-4f03-d608-103a5026146d@achow101.com> <5a4697cb-b9cb-b925-e78f-d5b53f025704@achow101.com> <40089cb5-8d68-1868-c87b-241f2bd747fb@achow101.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [bitcoin-dev] New PSBT version proposal 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: Thu, 21 Jan 2021 19:51:10 -0000 While working on the reference implementation for this, it occurred to=20 me that the Inputs Modifiable flag needs to be more than just a boolean. If there are existing signatures in the PSBT, then any added inputs=20 cannot change the transaction's locktime as all signatures, regardless=20 of sighash type, commit to the locktime. Additionally if an input with a=20 signature is being added, it also needs to set the locktime for the=20 transaction. It also seems like the SIGHASH_SINGLE bitmap is unnecessary. Signers can=20 instead iterate all inputs, check for existing signatures, and extract=20 the sighash byte from those signatures to determine whether any are=20 SIGHASH_SINGLE. This bitmap doesn't seem to provide much benefit and=20 also causes headaches for implementation. So I've decided to remove it. But it is still useful to know that there are SIGHASH_SINGLE inputs and=20 that iteration of the inputs vector will be necessary. It is also useful=20 to know that there are already some signatures in the transaction so the=20 locktime must be preserved. Thus I would like to change=20 PSBT_GLOBAL_TX_MODIFIABLE to include those. I propose making=20 PSBT_GLOBAL_TX_MODIFIABLE an 8 bit unsigned little endian integer that=20 is treated as a bit field. If bit 0 is set, inputs may be added. This=20 will be the Inputs Modifiable flag. If bit 1 is set, outputs may be=20 added. This will be the Outputs Modifiable flag. If bit 2 is set, the=20 transaction contains signatures and locktime must be preserved. This=20 will be the Has Signatures flag. If bit 3 is set, the transaction=20 contains SIGHASH_SINGLE inputs and their index pairings must be=20 preserved. This will be the Has SIGHASH_SINGLE flag. Changing PSBT_GLOBAL_TX_MODIFIABLE to a bitfield like this allows us to=20 include more conditions that need to be considered when adding inputs=20 and outputs. I think these are all of the conditions for now, but with 8=20 bits, there is still some space for additional conditions in the future.=20 Perhaps it should be changed to be larger if we think there will be more=20 conditions, but I think that is unlikely. Andrew On 1/15/21 12:28 PM, Andrew Chow wrote: > Hi All, > > I've made some reorganization changes to the way that new PSBT versions > should be handled in BIP 174 (see > https://github.com/bitcoin/bips/pull/1055) so PSBTv2 will be submitted > as a separate BIP. The full document can be read at > https://github.com/achow101/bips/blob/psbt2/bip-psbt2.mediawiki and I > have also included it in this email. > > I've included Rusty's suggestion for PSBT_GLOBAL_UNDER_CONSTRUCTION and > made a few modifications. First, the field will be named > PSBT_GLOBAL_TX_MODIFIABLE and only include the inputs modifiable and > outputs modifiable flags. The SIGHASH_SINGLE bitmap will be included as > a separate field PSBT_GLOBAL_SIGHASH_SINGLE_INPUTS. This allows most > PSBTs to not have to carry around a useless bitmap. > > Andrew > > *** > >
>   =C2=A0 BIP: PSBTv2
>   =C2=A0 Layer: Applications
>   =C2=A0 Title: PSBT Version 2
>   =C2=A0 Author: Andrew Chow 
>   =C2=A0 Comments-Summary: No comments yet.
>   =C2=A0 Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP-=
PSBT2
>   =C2=A0 Status: Draft
>   =C2=A0 Type: Standards Track
>   =C2=A0 Created: 2021-01-14
>   =C2=A0 License: BSD-2-Clause
> 
> > =3D=3DIntroduction=3D=3D > > =3D=3D=3DAbstract=3D=3D=3D > > This document proposes a second version of the Partially Signed Bitcoin > Transaction format > described in BIP 174 which allows for inputs and outputs to be added to > the PSBT after creation. > > =3D=3D=3DCopyright=3D=3D=3D > > This BIP is licensed under the 2-clause BSD license. > > =3D=3D=3DMotivation=3D=3D=3D > > Partially Signed Bitcoin Transaction Version 0 as described in BIP 174 > is unable to have new > inputs and outputs be added to the transaction. The fixed global > unsigned transaction > cannot be changed which prevents any additional inputs or outputs to be > added. > PSBT Version 2 is intended to rectify this problem. > > An additional benficial side effect is that all information for a given > input or output will be > provided by its or . With > Version 0, to retrieve > all of the information for an input or output, data would need to be > found in two locations: > the / and the global unsigned > transaction. PSBT > Version 2 now moves all related information to one place. > > =3D=3DSpecification=3D=3D > > PSBT Version 2 (PSBTv2) only specifies new fields and field > inclusion/exclusion requirements. > > PSBT_GLOBAL_UNSIGNED_TX must be excluded in PSBTv2. > PSBT_GLOBAL_VERSION must be included in PSBTv2 and set to > version number 2'''What happened to version number 1?''' > Version number 1 is skipped because PSBT Version 0 has been colloquially > referred to as version 1. Originally this BIP was to be > version 1, but because it has been colloquially referred to as version 2 > during its design phrase, it was decided to change the > version number to 2 so that there would not be any confusion. > > The new global types for PSBT Version 2 are as follows: > > {| > ! Name > ! > ! > ! Description > ! > ! Description > ! Versions Requiring Inclusion > ! Versions Requiring Exclusion > ! Versions Allowing Inclusion > |- > | Transaction Version > | PSBT_GLOBAL_TX_VERSION =3D 0x02 > | None > | No key data > | <32-bit uint> > | The 32-bit little endian signed integer representing the version > number of the transaction being created. Note that this is not the same > as the PSBT version number specified by the PSBT_GLOBAL_VERSION field. > | 2 > | 0 > | 2 > |- > | Fallback Locktime > | PSBT_GLOBAL_FALLBACK_LOCKTIME =3D 0x03 > | None > | No key data > | <32-bit uint> > | The 32-bit little endian unsigned integer representing the transaction > locktime to use if no inputs specify a required locktime. > | > | 0 > | 2 > |- > | Input Count > | PSBT_GLOBAL_INPUT_COUNT =3D 0x04 > | None > | No key data > | > | Compact size unsigned integer representing the number of inputs in > this PSBT. > | 2 > | 0 > | 2 > |- > | Output Count > | PSBT_GLOBAL_OUTPUT_COUNT =3D 0x05 > | None > | No key data > | > | Compact size unsigned integer representing the number of outputs in > this PSBT. > | 2 > | 0 > | 2 > |- > | Transaction Modifiable Flags > | PSBT_GLOBAL_TX_MODIFIABLE =3D 0x06 > | None > | No key data > | > | A single byte boolean (0 for False, 1 for True) representing whether > inputs can be modified, referred to as the Inputs Modifiable Flag. This > is followed by a single byte boolean representing whether outputs can be > modified, referred to as the Outputs Modifiable Flag. > | > | 0 > | 2 > |- > | SIGHASH_SINGLE Inputs > | PSBT_GLOBAL_SIGHASH_SINGLE_INPUTS =3D 0x07 > | None > | No key data > | > | A bit vector representing which input indexes use SIGHASH_SINGLE. If > the bit for an index is set to 1, then the input and output pair at that > index are tied together with SIGHASH_SINGLE and must be moved together. > | > | 0 > | 2 > |} > > The new per-input types for PSBT Version 2 are defined as follows: > > {| > ! Name > ! > ! > ! Description > ! > ! Description > ! Versions Requiring Inclusion > ! Versions Requiring Exclusion > ! Versions Allowing Inclusion > |- > | Previous TXID > | PSBT_IN_PREVIOUS_TXID =3D 0x0e > | None > | No key data > | > | 32 byte txid of the previous transaction whose output at > PSBT_IN_OUTPUT_INDEX is being spent. > | 2 > | 0 > | 2 > |- > | Spent Output Index > | PSBT_IN_OUTPUT_INDEX =3D 0x0f > | None > | No key data > | <32-bit uint> > | 32 bit little endian integer representing the index of the output > being spent in the transaction with the txid of PSBT_IN_PREVIOUS_TXID. > | 2 > | 0 > | 2 > |- > | Sequence Number > | PSBT_IN_SEQUENCE =3D 0x10 > | None > | No key data > | <32-bit uint> > | The 32 bit unsigned little endian integer for the sequence number of > this input. If omitted, the sequence number is assumed to be the final > sequence number (0xffffffff). > | > | 0 > | 2 > |- > | Required Time-based Locktime > | PSBT_IN_REQUIRED_TIME_LOCKTIME =3D 0x11 > | None > | No key data > | <32-bit uint> > | 32 bit unsigned little endian integer greater than or equal to > 500000000 representing the minimum Unix timestamp that this input > requires to be set as the transaction's lock time. > | > | 0 > | 2 > |- > | Required Height-based Locktime > | PSBT_IN_REQUIRED_HEIGHT_LOCKTIME =3D 0x12 > | None > | No key data > | <32-bit uiht> > | 32 bit unsigned little endian integer less than 500000000 representing > the minimum block height that this input requires to be set as the > transaction's lock time. > | > | 0 > | 2 > |} > > The new per-output types for PSBT Version 2 are defined as follows: > > {| > ! Name > ! > ! > ! Description > ! > ! Description > ! Versions Requiring Inclusion > ! Versions Requiring Exclusion > ! Versions Allowing Inclusion > |- > | Output Amount > | PSBT_OUT_AMOUNT =3D 0x03 > | None > | No key data > | <64-bit uint> > | 64 bit signed little endian integer representing the output's amount > in satoshis. > | 2 > | 0 > | 2 > |- > | Output Script > | PSBT_OUT_SCRIPT =3D 0x03 > | None > | No key data > |