diff --git a/src/Makefile.am b/src/Makefile.am index d002e2e4fe03..61fe3eaae260 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -290,6 +290,7 @@ BITCOIN_CORE_H = \ interfaces/handler.h \ interfaces/init.h \ interfaces/ipc.h \ + interfaces/masternode_operator.h \ interfaces/node.h \ interfaces/providertx.h \ interfaces/wallet.h \ @@ -500,6 +501,7 @@ BITCOIN_CORE_H = \ wallet/fees.h \ wallet/hdchain.h \ wallet/load.h \ + wallet/masternode_operator_types.h \ wallet/platformkeys.h \ wallet/platformtypes.h \ wallet/receive.h \ @@ -741,6 +743,7 @@ libbitcoin_wallet_a_SOURCES = \ wallet/hdchain.cpp \ wallet/interfaces.cpp \ wallet/load.cpp \ + wallet/masternode_operator.cpp \ wallet/platformkeys.cpp \ wallet/receive.cpp \ wallet/rpc/addresses.cpp \ diff --git a/src/Makefile.test.include b/src/Makefile.test.include index 90a0ed75ed64..e7c47a06a967 100644 --- a/src/Makefile.test.include +++ b/src/Makefile.test.include @@ -230,6 +230,7 @@ if ENABLE_WALLET BITCOIN_TESTS += \ wallet/test/bip39_tests.cpp \ wallet/test/coinjoin_tests.cpp \ + wallet/test/masternode_operator_tests.cpp \ wallet/test/platformkeys_tests.cpp \ wallet/test/psbt_wallet_tests.cpp \ wallet/test/spend_tests.cpp \ diff --git a/src/bls/bls.h b/src/bls/bls.h index ae2124cd38e1..f08f448a914e 100644 --- a/src/bls/bls.h +++ b/src/bls/bls.h @@ -283,6 +283,13 @@ class CBLSSecretKey : public CBLSWrapper bytes) const + { + if (!IsValid() || bytes.size() != SerSize) return false; + impl.Serialize(bytes.data()); + return true; + } + void AggregateInsecure(const CBLSSecretKey& o); static CBLSSecretKey AggregateInsecure(Span sks); diff --git a/src/interfaces/masternode_operator.h b/src/interfaces/masternode_operator.h new file mode 100644 index 000000000000..6bbfeadb285a --- /dev/null +++ b/src/interfaces/masternode_operator.h @@ -0,0 +1,43 @@ +// Copyright (c) 2026 The Dash Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_INTERFACES_MASTERNODE_OPERATOR_H +#define BITCOIN_INTERFACES_MASTERNODE_OPERATOR_H + +#include + +#include +#include +#include + +namespace interfaces { + +//! Result of a deterministic masternode operator-key operation. +enum class MasternodeOperatorKeyStatus : uint8_t { + SUCCESS, + NOT_SUPPORTED, + WALLET_LOCKED, + EXHAUSTED, + INVALID_KEY, + NOT_FOUND, + DATABASE_ERROR, + DERIVATION_ERROR, +}; + +//! A deterministic masternode operator key returned by the wallet. The public +//! key uses the canonical basic-scheme serialization. +struct MasternodeOperatorKey { + SecureVector secret_key; + std::vector public_key; + std::string path; +}; + +struct MasternodeOperatorKeyResult { + MasternodeOperatorKeyStatus status{MasternodeOperatorKeyStatus::DERIVATION_ERROR}; + MasternodeOperatorKey key; +}; + +} // namespace interfaces + +#endif // BITCOIN_INTERFACES_MASTERNODE_OPERATOR_H diff --git a/src/interfaces/node.h b/src/interfaces/node.h index 5713fceaa88e..31fc62e3769e 100644 --- a/src/interfaces/node.h +++ b/src/interfaces/node.h @@ -32,6 +32,7 @@ class BanMan; class CBlockIndex; +class CBLSPublicKey; class CDeterministicMNList; class CFeeRate; class CGovernanceObject; @@ -182,6 +183,15 @@ class EVO virtual ProviderTxResult updateShare(Wallet& wallet, const SharedUpdateShareRequest& request) = 0; virtual ProviderTxResult prepareSharedRegistrarUpdate( Wallet& wallet, const SharedRegistrarUpdatePrepareRequest& request) = 0; + /** + * Whether an operator public key is assigned to any masternode in the + * deterministic list at the current chain tip, under either BLS scheme + * encoding. This is a UX guard for skipping keys that would be rejected + * by DIP3 duplicate-key checks, not a safety mechanism: when the node is + * not ready to answer (no tip or no masternode manager yet), it returns + * false. Keys used only historically also return false. + */ + virtual bool isMasternodeOperatorKeyInUse(const CBLSPublicKey& public_key) = 0; virtual void setContext(node::NodeContext* context) {} }; diff --git a/src/interfaces/wallet.h b/src/interfaces/wallet.h index 641579241315..07ab7f96988f 100644 --- a/src/interfaces/wallet.h +++ b/src/interfaces/wallet.h @@ -8,6 +8,7 @@ #include // For CAmount #include #include // For ChainClient +#include #include // For CKeyID and CScriptID (definitions needed in CTxDestination instantiation) #include