From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 97D77C000E for ; Thu, 22 Jul 2021 14:44:17 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 7FB69605C9 for ; Thu, 22 Jul 2021 14:44:17 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org X-Spam-Flag: NO X-Spam-Score: -2.8 X-Spam-Level: X-Spam-Status: No, score=-2.8 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no Authentication-Results: smtp3.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=riseup.net Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qAiY64jrvYK7 for ; Thu, 22 Jul 2021 14:44:16 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from mx1.riseup.net (mx1.riseup.net [198.252.153.129]) by smtp3.osuosl.org (Postfix) with ESMTPS id C5299605B7 for ; Thu, 22 Jul 2021 14:44:16 +0000 (UTC) Received: from fews1.riseup.net (fews1-pn.riseup.net [10.0.1.83]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client CN "*.riseup.net", Issuer "Sectigo RSA Domain Validation Secure Server CA" (not verified)) by mx1.riseup.net (Postfix) with ESMTPS id 4GVwFX2CLVzF4yd for ; Thu, 22 Jul 2021 07:44:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1626965056; bh=Y/6yy89a2IgmrfX/l2eY2nj2TtXibe8FIdt8xTkePF8=; h=Subject:From:To:References:Date:In-Reply-To:From; b=ObJklJdXv2/FK56aKl0/MFgDVu6HAW2+rzybDWJ36gzkzwOD5zFk8jSAZu/yX2yhQ hqhooF5i75h4sIOU2A8JwkonwYee4h4DQqF0hMTW2z20ZRoHmnjbgE2QOHqIvhc5RG Z1vYlaQsl2gEk/+qSflKlrJR83+ULePyp1uOXJw4= X-Riseup-User-ID: 2081AF62FAFC6FE02DBD69E0C7F371E119D17F3DC168DC2B3CBFDE06B6115D4C Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews1.riseup.net (Postfix) with ESMTPSA id 4GVwFW5ZrMz5w7Q for ; Thu, 22 Jul 2021 07:44:15 -0700 (PDT) From: Chris Belcher To: bitcoin-dev@lists.linuxfoundation.org References: <3dc2e965-77c6-f923-4c00-0cbea7b6d9e5@riseup.net> Message-ID: <5c367528-5fc9-1225-5c32-150e71a9de45@riseup.net> Date: Thu, 22 Jul 2021 15:44:11 +0100 MIME-Version: 1.0 In-Reply-To: <3dc2e965-77c6-f923-4c00-0cbea7b6d9e5@riseup.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [bitcoin-dev] BIP proposal: Anti-fee-sniping protection with nSequence in taproot transactions to improve privacy for off-chain protocols 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, 22 Jul 2021 14:44:17 -0000 Hello list, Someone reviewing my taproot privacy BIP proposal suggested clarification on the spec, so I've written some python-like pseudocode. It implements the suggestion of choosing a random input instead of the first one. Some wallet teams are already working on implementing taproot for their on-chain app. I urge wallet developers to include this BIP as well, so that their user's spends will improve the privacy and fungibility of off-chain protocols. Also, and admittedly a less urgently, anti-fee-sniping will improve the incentives for miners in the low-inflation future of bitcoin. As before find the latest version of this BIP here: https://gist.github.com/chris-belcher/903feab321bf41055c91eaec46581e89 def apply_anti_fee_sniping_fields(transaction): # bip68 requires v=2 transaction.version = 2 # always set nlocktime if any of the transaction inputs have more # confirmations than 65535 or are taproot inputs # otherwise choose either nlocktime or nsequence with 50% odds if any(map(lambda input: input.confirmations() > 65535 || input.is_taproot(), transaction.inputs))\ || randint(2) == 0: transaction.nlocktime = blockchain.height() if randint(10) == 0: transaction.nlocktime = max(0, transaction.nlocktime - randint(0, 99)) else: input_index = randint(len(transaction.inputs)) transaction.inputs[input_index].nsequence = transaction.inputs\ [input_index].confirmations() if randint(10) == 0: transaction.inputs[input_index].nsequence = max(0, transaction.inputs[input_index].nsequence - randint(0, 99))