diff options
author | Wladimir J. van der Laan <laanwj@protonmail.com> | 2020-09-21 22:32:05 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@protonmail.com> | 2020-09-21 22:33:00 +0200 |
commit | 8c5f68118cd03ff0b9babee351fee83117fb7afa (patch) | |
tree | e38b0f179c5440fcb835b6408d05690949d57172 /src/signet.h | |
parent | c0c409dcd330e8b837291b1d331894aeb0015ead (diff) | |
parent | 8258c4c0076bb5f27efdc117a04b27fcd6dd00b2 (diff) | |
download | bitcoin-8c5f68118cd03ff0b9babee351fee83117fb7afa.tar.xz |
Merge #18267: BIP-325: Signet [consensus]
8258c4c0076bb5f27efdc117a04b27fcd6dd00b2 test: some sanity checks for consensus logic (Anthony Towns)
e47ad375bf17557f805bd206e789b8db78c6338a test: basic signet tests (Karl-Johan Alm)
4c189abdc452f08dfa758564b5381bc78c42d481 test: add small signet fuzzer (practicalswift)
ec9b25d046793be50da1c11ba61d1b4b13b295b0 test: signet network selection tests (Karl-Johan Alm)
3efe298dccb248f25d6b01ab6a80b1cd6c9e1a1e signet: hard-coded parameters for Signet Global Network VI (2020-09-07) (Karl-Johan Alm)
c7898bca4e1ccbc6edafd3b72eaf80df38e3af32 qt: update QT to support signet network (Karl-Johan Alm)
a8de47a1c9033fac3355590f1fe2158a95011bb3 consensus: add signet validation (Karl-Johan Alm)
e8990f121405af8cd539b904ef082439261e6c93 add signet chain and accompanying parameters (Karl-Johan Alm)
404682b7cdb54494e7c98f0ba0cac8b51f379750 add signet basic support (signet.cpp) (Karl-Johan Alm)
a2147d7dadec1febcd9c2b8ebbbf78dce6d0556b validation: move GetWitnessCommitmentIndex to consensus/validation (Karl-Johan Alm)
Pull request description:
This PR is a part of BIP-325 (https://github.com/bitcoin/bips/blob/master/bip-0325.mediawiki), and is a sub-PR of #16411.
* Signet consensus (this)
* Signet RPC tools (pending)
* Signet utility scripts (contrib/signet) (pending)
ACKs for top commit:
jonatack:
re-ACK 8258c4c0076bb5f27efdc117a04b27fcd6dd00b per `git diff dbeea65 8258c4c`, only change since last review is updated `-signet*` config option naming.
fjahr:
re-ACK 8258c4c
laanwj:
ACK 8258c4c0076bb5f27efdc117a04b27fcd6dd00b2
MarcoFalke:
Approach ACK 8258c4c007 🌵
Tree-SHA512: 5d158add96755910837feafa8214e13695b769a6aec3a2da753cf672618bef377fac43b0f4b772a87b25dd9f0c1c9b29f2789785d7a7d47a155cdcf48f7c975d
Diffstat (limited to 'src/signet.h')
-rw-r--r-- | src/signet.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/signet.h b/src/signet.h new file mode 100644 index 0000000000..5694716fb6 --- /dev/null +++ b/src/signet.h @@ -0,0 +1,42 @@ +// Copyright (c) 2019-2020 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_SIGNET_H +#define BITCOIN_SIGNET_H + +#include <consensus/params.h> +#include <primitives/block.h> +#include <primitives/transaction.h> + +/** + * Extract signature and check whether a block has a valid solution + */ +bool CheckSignetBlockSolution(const CBlock& block, const Consensus::Params& consensusParams); + +/** + * Generate the signet tx corresponding to the given block + * + * The signet tx commits to everything in the block except: + * 1. It hashes a modified merkle root with the signet signature removed. + * 2. It skips the nonce. + */ +class SignetTxs { +private: + struct invalid {}; + SignetTxs(invalid i) : m_to_spend(), m_to_sign(), m_valid(false) { } + + template<class T1, class T2> + SignetTxs(const T1& to_spend, const T2& to_sign) : m_to_spend{to_spend}, m_to_sign{to_sign}, m_valid(true) { } + + static SignetTxs Create(const CBlock& block, const CScript& challenge); + +public: + SignetTxs(const CBlock& block, const CScript& challenge) : SignetTxs(Create(block, challenge)) { } + + const CTransaction m_to_spend; + const CTransaction m_to_sign; + const bool m_valid; +}; + +#endif // BITCOIN_SIGNET_H |