Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YmLXf-0002Ph-U2 for bitcoin-development@lists.sourceforge.net; Sun, 26 Apr 2015 12:20:11 +0000 Received: from mail-wi0-f177.google.com ([209.85.212.177]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1YmLXe-00024e-QA for bitcoin-development@lists.sourceforge.net; Sun, 26 Apr 2015 12:20:11 +0000 Received: by wizk4 with SMTP id k4so69662482wiz.1 for ; Sun, 26 Apr 2015 05:20:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=oIPq6gndlISv/8pEY6dTt8KNk5a6tn86e3Gu2hIupvg=; b=AaaoN5vmo7gqzWE0eUs+3gceNSFwT8VkYV8cyg0wcRsNmzLg83YEPHG/ThRIUaHreR GNgCZwQ3J0WtUs/S7fGl3QZv/X3L0IM5pK1TkfEIhl0NeS3CWgSY2qDTEhMidQaA+c+H aKLUfWQ0pwaYSjfUaOOTNDXjZ4VB2Lpomslwv9WbIsfm/wlvef8Dc5Mbln+rWaIFfJuI cGZXxg7B5PImxwrP2wqUu0a042gKqainjQEjeBEDUJa0PLYmyI0JOXuWUiydP0sPIGLG PVU21tOQtr5ZMxJFwr61bupPzFCNWRWjoLU9vskUBmADt5tl3N7uYqzgXwBplEepsB5u lg+g== X-Gm-Message-State: ALoCoQmGxO3oEHuiQH8qWhmLBk76Mvqqjq2Jn/xAs4v4oJ1KdMjNbeSAW4oWkcyJG1na8hj07ws3 MIME-Version: 1.0 X-Received: by 10.180.99.166 with SMTP id er6mr12436873wib.58.1430050804626; Sun, 26 Apr 2015 05:20:04 -0700 (PDT) Received: by 10.194.124.2 with HTTP; Sun, 26 Apr 2015 05:20:04 -0700 (PDT) In-Reply-To: References: <20141001130826.GM28710@savin.petertodd.org> <55075795.20904@bluematt.me> <20150421075912.GA25282@savin.petertodd.org> Date: Sun, 26 Apr 2015 14:20:04 +0200 Message-ID: From: =?UTF-8?B?Sm9yZ2UgVGltw7Nu?= To: Peter Todd Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. X-Headers-End: 1YmLXe-00024e-QA Cc: Bitcoin Dev Subject: Re: [Bitcoin-development] Relative CHECKLOCKTIMEVERIFY (was CLTV proposal) X-BeenThere: bitcoin-development@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 26 Apr 2015 12:20:12 -0000 On Sun, Apr 26, 2015 at 1:35 PM, Jorge Tim=C3=B3n wrote: > There's another possibility that could keep the utxo out of Script verifi= cation: > > class CTxIn > { > public: > COutPoint prevout; > CScript scriptSig; > uint32_t nSequence; > } > > could turn into: > > class CTxIn > { > public: > COutPoint prevout; > CScript scriptSig; > uint32_t nHeight; > } > > And a new softfork rule could enforce that all new CTxIn set nHeight > to the correct height in which its corresponding prevout got into the > chain. > That would remove the need for the TxOutputGetter param in > bitcoinconsensus_verify_script, but unfortunately it is not reorg safe > (apart from other ugly implementation details). Wait, wait, this can be made reorg-safe and more backards compatible. The new validation rule at the tx validation level (currently in main::CheckInputs()) would be for (unsigned int i =3D 0; i < tx.vin.size(); i++) { // ... if (tx.vin.nHeight + 100 > tx.nLockTime) return state.Invalid(false, REJECT_INVALID, "bad-txns-vin-height-reorg-unsafe"); if (coins->nHeight > tx.vin.nHeight) return state.Invalid(false, REJECT_INVALID, "bad-txns-vin-height-false"); // ... } Existing transactions that have used the deprecated CTxIn::nSequence for something else will be fine if they've used low nSequences. The only concern would be breaking some colored coins kernels, but there's many others implemented that don't rely on CTxIn::nSequence. Transactions that want to use OP_MATURITY just have to set the corresponding CTxIn::nHeight and CTransaction::nLockTime properly. This way op_maturity wouldn't require anything from the utxo and the final interface could be: int bitcoinconsensus_verify_script(const unsigned char* scriptPubKey, unsigned int scriptPubKeyLen, const unsigned char* txTo, unsigned int txToLen, unsigned int nIn, unsigned int nHei= ght, unsigned int flags, secp256k1_context_t* ctx, bitcoinconsensus_error* err);