Return-Path: Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0F10EC0001 for ; Wed, 10 Mar 2021 00:21:28 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 099A44EBC2 for ; Wed, 10 Mar 2021 00:21:28 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org X-Spam-Flag: NO X-Spam-Score: -2.099 X-Spam-Level: X-Spam-Status: No, score=-2.099 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, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no Authentication-Results: smtp4.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QHeYVhkIbAU4 for ; Wed, 10 Mar 2021 00:21:26 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by smtp4.osuosl.org (Postfix) with ESMTPS id 2E50D4EBBF for ; Wed, 10 Mar 2021 00:21:26 +0000 (UTC) Received: by mail-pl1-x635.google.com with SMTP id a24so7565533plm.11 for ; Tue, 09 Mar 2021 16:21:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=iM56/QbSksUNXb66CrEdatJZCcoCwWLAEkqFSJ0fLcY=; b=HE2dSRSKlAtiNSF04jfCSdmHFHy6kZ2ATpE0Kw3dv79YP9yL2D8zt4E6sZBnlobz79 HAyarpGTKVlfFwuAWBHL9ms8baa0NGablEQoMmkaOC0jGL+pSH8SAxpYRgZHGje17sIN 0PO1qUs0xxGWfanCafr2VNEQ8iIerOB8f906u9XVkIB4zJH8rXHd0z+q9O0WrUjxdFgZ jo1VZsbxlF2sE+KPUIV3DxyHBJlZ0I8PX2FXeQzvbVvNT8uKDFLHSLACdGe1NieyoVpz dCPUYGkNLQw4pQlkMhehmYs8OiAjStqD7jkbZx71D3+V0YuBH9Wgq7dHjzyvu3HsBGT3 7MpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=iM56/QbSksUNXb66CrEdatJZCcoCwWLAEkqFSJ0fLcY=; b=bJ1o77mkyV/XqtDmx5MtsENtr5N7Z+ifBN6StyQ50IrYx9GVmnqLu+htdigcD3gZdP mpQDBwAWhTHug0ikP9sRd+5213npidqPkpum2qyXWU53YkIn5U8yOCQJXhdIqDFChfQ9 zuijW0xBS98EbvTogEL/jLrwsw9DVkx2vki+DDP/nhkV201vsswf7VpBY0wyhTMqz3dc 4uMMtWXj5sLj84B6sCfP9nvBI/aC1aPkBIwuUftBuPSLK4A06kDPxmRcjvLJ5QnOM1+H emgqnUQk4lfZX92aGZwHChtduWllsvpTVC0G9asrhBTRa0NLBS6tVlzdYGoFPMnA0TXe +XYw== X-Gm-Message-State: AOAM530IW37hAsauZMVn3SMUl3YRMG+FWM6a5IvFpiqNzPjiM7oQFk79 G9UTBP8g3edOKbtUclEXZCfjyP+r0OfGf9EcPNhkMiSksao= X-Google-Smtp-Source: ABdhPJzY8KZiuPl+Rbo0V920F3MA+aZTYrwgre72wr25Y+71zlxDkBgU1xJwUwZRKSLXjjjlmo6HqxCR0DjpBiBhywg= X-Received: by 2002:a17:902:59c9:b029:e6:5cdd:f709 with SMTP id d9-20020a17090259c9b02900e65cddf709mr416311plj.20.1615335685432; Tue, 09 Mar 2021 16:21:25 -0800 (PST) MIME-Version: 1.0 References: <1dd8c285-e3f4-4f03-d608-103a5026146d@achow101.com> In-Reply-To: <1dd8c285-e3f4-4f03-d608-103a5026146d@achow101.com> From: Lloyd Fournier Date: Wed, 10 Mar 2021 11:20:58 +1100 Message-ID: To: Andrew Chow , Bitcoin Protocol Discussion Content-Type: multipart/alternative; boundary="000000000000b92b6a05bd23a520" X-Mailman-Approved-At: Wed, 10 Mar 2021 00:53:23 +0000 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: Wed, 10 Mar 2021 00:21:28 -0000 --000000000000b92b6a05bd23a520 Content-Type: text/plain; charset="UTF-8" Hi Andrew & all, I've been working with PSBTs for a little while now. FWIW I agree with the change of removing the global tx and having the input/output data stored together in the new unified structures. One thing I've been wondering about is how output descriptors could fit into PSBTs. They are useful since they allow you to determine the maximum satisfaction weight for inputs so you can properly align fees as things get added. I haven't seen any discussion about including them in this revision. Is it simply a matter of time before they make it into a subsequent PSBT spec or is there something I'm missing conceptually? Cheers, LL On Thu, 10 Dec 2020 at 09:33, Andrew Chow via bitcoin-dev < bitcoin-dev@lists.linuxfoundation.org> wrote: > Hi All, > > I would like to propose a new PSBT version that addresses a few > deficiencies in the current PSBT v0. As this will be backwards > incompatible, a new PSBT version will be used, v1. > > The primary change is to truly have all input and output data for each > in their respective maps. Instead of having to parse an unsigned > transaction and lookup some data from there, and other data from the > correct map, all of the data for an input will be contained in its map. > Doing so also disallows PSBT_GLOBAL_UNSIGNED_TX in this new version. > Thus I propose that the following fields be added: > > Global: > * PSBT_GLOBAL_TX_VERSION = 0x02 > * Key: empty > * Value: 32-bit little endian unsigned integer for the transaction > version number. Must be provided in PSBT v1 and omitted in v0. > * PSBT_GLOBAL_PREFERRED_LOCKTIME = 0x03 > * Key: empty > * Value: 32 bit little endian unsigned integer for the preferred > transaction lock time. Must be omitted in PSBT v0. May be provided in > PSBT v1, assumed to be 0 if not provided. > * PSBT_GLOBAL_INPUT_COUNT = 0x04 > * Key: empty > * Value: Compact size unsigned integer. Number of inputs in this > PSBT. Must be provided in PSBT v1 and omitted in v0. > * PSBT_GLOBAL_OUTPUT_COUNT = 0x05 > * Key: empty > * Value: Compact size unsigned integer. Number of outputs in this > PSBT. Must be provided in PSBT v1 and omitted in v0. > > Input: > * PSBT_IN_PREVIOUS_TXID = 0x0e > * Key: empty > * Value: 32 byte txid of the previous transaction whose output at > PSBT_IN_OUTPUT_INDEX is being spent. Must be provided in PSBT v1 and > omitted in v0. > * PSBT_IN_OUTPUT_INDEX = 0x0f > * Key: empty > * Value: 32 bit little endian integer for the index of the output > being spent. Must be provided in PSBT v1 and omitted in v0. > * PSBT_IN_SEQUENCE = 0x0f > * Key: empty > * Value: 32 bit unsigned little endian integer for the sequence > number. Must be omitted in PSBT v0. May be provided in PSBT v1 assumed > to be max sequence (0xffffffff) if not provided. > * PSBT_IN_REQUIRED_LOCKTIME = 0x10 > * Key: empty > * Value: 32 bit unsigned little endian integer for the lock time that > this input requires. Must be omitted in PSBT v0. May be provided in PSBT > v1, assumed to be 0 if not provided. > > Output: > * PSBT_OUT_VALUE = 0x03 > * Key: empty > * Value: 64-bit unsigned little endian integer for the output's > amount in satoshis. Must be provided in PSBT v1 and omitted in v0. > * PSBT_OUT_OUTPUT_SCRIPT = 0x04 > * Key: empty > * Value: The script for this output. Otherwise known as the > scriptPubKey. Must be provided in PSBT v1 and omitted in v0. > > This change allows for PSBT to be used in the construction of > transactions. With these new fields, inputs and outputs can be added as > needed. One caveat is that there is no longer a unique transaction > identifier so more care must be taken when combining PSBTs. > Additionally, adding new inputs and outputs must be done such that > signatures are not invalidated. This may be harder to specify. > > An important thing to note in this proposal are the fields > PSBT_GLOBAL_PREFERRED_LOCKTIME and PSBT_IN_REQUIRED_LOCKTIME. A Bitcoin > transaction only has a single locktime yet a PSBT may have multiple > locktimes. To choose the locktime for the transaction, finalizers must > choose the maximum of all of the *_LOCKTIME fields. > PSBT_IN_REQUIRED_LOCKTIME is added because some inputs, such as those > involving OP_CHECKLOCKTIMEVERIFY, require a specific minimum locktime to > be set. This field allows finalizers to choose a locktime that is high > enough for all inputs without needing to understand the scripts > involved. The PSBT_GLOBAL_PREFERRED_LOCKTIME is the locktime to use if > no inputs require a particular locktime. > > As these changes disallow the PSBT_GLOBAL_UNSIGNED_TX field, PSBT v1 > needs the version number bump to enforce backwards incompatibility. > However once the inputs and outputs of a PSBT are decided, a PSBT could > be "downgraded" back to v0 by creating the unsigned transaction from the > above fields, and then dropping these new fields. > > If the list finds that these changes are reasonable, I will write a PR > to modify BIP 174 to incorporate them. > > Thanks, > Andrew Chow > > _______________________________________________ > bitcoin-dev mailing list > bitcoin-dev@lists.linuxfoundation.org > https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev > --000000000000b92b6a05bd23a520 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Andrew & all,

I'v= e been working with PSBTs for a little while now. FWIW I agree with the cha= nge of removing the global tx and having the input/output data stored toget= her in the new unified structures.

One thing I'= ;ve been wondering about is how output descriptors could fit into PSBTs. Th= ey are useful since they allow you to determine the maximum satisfaction we= ight for inputs so you can properly align fees as things get added. I haven= 't seen any discussion about including them in this revision. Is it sim= ply a matter of time before they make it into a subsequent PSBT spec or is = there something I'm missing conceptually?

Chee= rs,

LL

On Thu, 10 Dec 2020 at 09:33, Andr= ew Chow via bitcoin-dev <bitcoin-dev@lists.linuxfoundation.org> wrote:
Hi All,

I would like to propose a new PSBT version that addresses a few
deficiencies in the current PSBT v0. As this will be backwards
incompatible, a new PSBT version will be used, v1.

The primary change is to truly have all input and output data for each
in their respective maps. Instead of having to parse an unsigned
transaction and lookup some data from there, and other data from the
correct map, all of the data for an input will be contained in its map. Doing so also disallows PSBT_GLOBAL_UNSIGNED_TX in this new version.
Thus I propose that the following fields be added:

Global:
* PSBT_GLOBAL_TX_VERSION =3D 0x02
=C2=A0=C2=A0 * Key: empty
=C2=A0=C2=A0 * Value: 32-bit little endian unsigned integer for the transac= tion
version number. Must be provided in PSBT v1 and omitted in v0.
* PSBT_GLOBAL_PREFERRED_LOCKTIME =3D 0x03
=C2=A0=C2=A0 * Key: empty
=C2=A0=C2=A0 * Value: 32 bit little endian unsigned integer for the preferr= ed
transaction lock time. Must be omitted in PSBT v0. May be provided in
PSBT v1, assumed to be 0 if not provided.
* PSBT_GLOBAL_INPUT_COUNT =3D 0x04
=C2=A0=C2=A0 * Key: empty
=C2=A0=C2=A0 * Value: Compact size unsigned integer. Number of inputs in th= is
PSBT. Must be provided in PSBT v1 and omitted in v0.
* PSBT_GLOBAL_OUTPUT_COUNT =3D 0x05
=C2=A0=C2=A0 * Key: empty
=C2=A0=C2=A0 * Value: Compact size unsigned integer. Number of outputs in t= his
PSBT. Must be provided in PSBT v1 and omitted in v0.

Input:
* PSBT_IN_PREVIOUS_TXID =3D 0x0e
=C2=A0=C2=A0 * Key: empty
=C2=A0=C2=A0 * Value: 32 byte txid of the previous transaction whose output= at
PSBT_IN_OUTPUT_INDEX is being spent. Must be provided in PSBT v1 and
omitted in v0.
* PSBT_IN_OUTPUT_INDEX =3D 0x0f
=C2=A0=C2=A0 * Key: empty
=C2=A0=C2=A0 * Value: 32 bit little endian integer for the index of the out= put
being spent. Must be provided in PSBT v1 and omitted in v0.
* PSBT_IN_SEQUENCE =3D 0x0f
=C2=A0=C2=A0 * Key: empty
=C2=A0=C2=A0 * Value: 32 bit unsigned little endian integer for the sequenc= e
number. Must be omitted in PSBT v0. May be provided in PSBT v1 assumed
to be max sequence (0xffffffff) if not provided.
* PSBT_IN_REQUIRED_LOCKTIME =3D 0x10
=C2=A0=C2=A0 * Key: empty
=C2=A0=C2=A0 * Value: 32 bit unsigned little endian integer for the lock ti= me that
this input requires. Must be omitted in PSBT v0. May be provided in PSBT v1, assumed to be 0 if not provided.

Output:
* PSBT_OUT_VALUE =3D 0x03
=C2=A0=C2=A0 * Key: empty
=C2=A0=C2=A0 * Value: 64-bit unsigned little endian integer for the output&= #39;s
amount in satoshis. Must be provided in PSBT v1 and omitted in v0.
* PSBT_OUT_OUTPUT_SCRIPT =3D 0x04
=C2=A0=C2=A0 * Key: empty
=C2=A0=C2=A0 * Value: The script for this output. Otherwise known as the scriptPubKey. Must be provided in PSBT v1 and omitted in v0.

This change allows for PSBT to be used in the construction of
transactions. With these new fields, inputs and outputs can be added as needed. One caveat is that there is no longer a unique transaction
identifier so more care must be taken when combining PSBTs.
Additionally, adding new inputs and outputs must be done such that
signatures are not invalidated. This may be harder to specify.

An important thing to note in this proposal are the fields
PSBT_GLOBAL_PREFERRED_LOCKTIME and PSBT_IN_REQUIRED_LOCKTIME. A Bitcoin transaction only has a single locktime yet a PSBT may have multiple
locktimes. To choose the locktime for the transaction, finalizers must
choose the maximum of all of the *_LOCKTIME fields.
PSBT_IN_REQUIRED_LOCKTIME is added because some inputs, such as those
involving OP_CHECKLOCKTIMEVERIFY, require a specific minimum locktime to be set. This field allows finalizers to choose a locktime that is high
enough for all inputs without needing to understand the scripts
involved. The PSBT_GLOBAL_PREFERRED_LOCKTIME is the locktime to use if
no inputs require a particular locktime.

As these changes disallow the PSBT_GLOBAL_UNSIGNED_TX field, PSBT v1
needs the version number bump to enforce backwards incompatibility.
However once the inputs and outputs of a PSBT are decided, a PSBT could be "downgraded" back to v0 by creating the unsigned transaction f= rom the
above fields, and then dropping these new fields.

If the list finds that these changes are reasonable, I will write a PR
to modify BIP 174 to incorporate them.

Thanks,
Andrew Chow

_______________________________________________
bitcoin-dev mailing list
= bitcoin-dev@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mail= man/listinfo/bitcoin-dev
--000000000000b92b6a05bd23a520--