Return-Path: Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 14F07AA6 for ; Tue, 4 Sep 2018 03:24:23 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-yb1-f175.google.com (mail-yb1-f175.google.com [209.85.219.175]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id B1B035E2 for ; Tue, 4 Sep 2018 03:24:22 +0000 (UTC) Received: by mail-yb1-f175.google.com with SMTP id t71-v6so779393ybi.7 for ; Mon, 03 Sep 2018 20:24:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=m0dueVg0KYxhDunIelNLbTFG2mTY8rnqXFgZR/3/yLQ=; b=YipwZN3okOCx6J+iB2iIy0HTFNobNw+wXvkP/bsSU0yz57VpnxiQmxDivkYTvtj87T VfqVVsTzGQj14V2+fsAfbQci+nw1GP9vLUdDA4PtORzttaVvVOm3lAAzpf2JhGHB4QqT 5GHXi3qIx9uUArhpMxLjxT3fwoHVyVRZ7oHU2QiPG60446FYaG4uoqt0uMv+hrbOJ1Ee nQpHa+Wb979rbCK/5hBhfmz1VDc4Ia+2Kof7uHZSYmMfakU5myUL0sHV7tXWM/fnugqR ++IzbqPywurN0LSJ5RYXMTWx8ZU/QCNf+PhVC31no3BlfiSfF4Iejtjs8+R42t66x4A5 OWtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=m0dueVg0KYxhDunIelNLbTFG2mTY8rnqXFgZR/3/yLQ=; b=PeLDtInlvRNpsYgiU6d7SUYQJu3OckoSsImdcR5blkdgBRKDNWSh0lWUU67S+p40s1 cUSQsv/4lEZHg67zKTnrxt5dn31p69pkt/t92bBACtIXO/DrhHu9rUE6ZXZxDUiZ9HsF UF0GhgUwCDnuM1ZCrFJV4i09xEi/2Ao63472NKG0BrIVIuIPQgG76PqWN67IQE0du2+c ROsrw/YaKZhCfJnEteBvTB9gR9Ku1oVaAamA1os1F9z5Nx05bilE3h8VfHOdOS+2QlHQ nNTGhPBRVYrnR26HCEinspZNo3+fRbheZkWplwCfgEGYog0Ai4GP0OulIFo8Zcg+w+iw nbFQ== X-Gm-Message-State: APzg51DjIzQrjUPVam7hS/ZEF8abZ/OVxDqePr83wIAsOxmr/6xms5Rw QwSnUha9pkESFYKF0jMK312q1AuSJvZ8IWOV/IH+XeY0 X-Google-Smtp-Source: ANB0VdYfekBHriGFeoYJ2bnEhIEqnZCz25LyB3GBv2tf1x1nGuC62tPXGzEcBeqACGm7x+GeWuXNwWQQMmdTTSLBD90= X-Received: by 2002:a25:e709:: with SMTP id e9-v6mr17748575ybh.358.1536031461860; Mon, 03 Sep 2018 20:24:21 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a81:84c5:0:0:0:0:0 with HTTP; Mon, 3 Sep 2018 20:24:01 -0700 (PDT) From: Alex Bosworth Date: Mon, 3 Sep 2018 20:24:01 -0700 Message-ID: To: bitcoin-dev@lists.linuxfoundation.org Content-Type: text/plain; charset="UTF-8" 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: Tue, 04 Sep 2018 11:32:01 +0000 Subject: [bitcoin-dev] Extending BIP174 for HTLCs 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: Tue, 04 Sep 2018 03:24:23 -0000 I've been experimenting with a format tag for BIP 174 to help support HTLC scripts I've been working with. Not sure on the best format for this, but what I have been thinking about is a new input type that defines elements that should be inserted in the final p2sh/p2wsh stack such as a preimage or a refund path flag. Type: Additional Stack Element ADDITIONAL_STACK_ELEMENT = 0xXX Key: The index in the stack to insert a value (uint32 LE) {0xXX}|{Stack index} Value: The value to push into the stack for a redeem script or witness script at the specified index. {value} So my flow is: 1. Create blank PSBT (attaching locktime, anticipating final weight to adjust outputs for fees) 2. Update with redeem scripts and/or witness scripts 3. Update with sighashes 4. Sign: generate partial signature 5. Attach additional stack elements for the required non-signature elements 6. Finalize to create the final scriptsig and/or witness 7. Extract the signed transaction for broadcast This may be overkill or overly generic, has anyone else thought of how to use PSBTs in an HTLC context? -- Sent from my iPhone