aboutsummaryrefslogtreecommitdiff
path: root/src/signet.h
diff options
context:
space:
mode:
authorKarl-Johan Alm <karljohan-alm@garage.co.jp>2019-07-17 17:41:32 +0900
committerKarl-Johan Alm <karljohan-alm@garage.co.jp>2020-09-10 10:47:40 +0900
commit404682b7cdb54494e7c98f0ba0cac8b51f379750 (patch)
treeefbf6c2ab88f7392185efefb5f77006c2db2cecc /src/signet.h
parenta2147d7dadec1febcd9c2b8ebbbf78dce6d0556b (diff)
downloadbitcoin-404682b7cdb54494e7c98f0ba0cac8b51f379750.tar.xz
add signet basic support (signet.cpp)
Co-authored-by: Anthony Towns <aj@erisian.com.au>
Diffstat (limited to 'src/signet.h')
-rw-r--r--src/signet.h42
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