diff options
author | Pieter Wuille <pieter@wuille.net> | 2021-02-27 20:33:22 -0800 |
---|---|---|
committer | Pieter Wuille <pieter@wuille.net> | 2021-06-12 12:25:28 -0700 |
commit | a2380127e905e5849f90acc7c69832859d8336aa (patch) | |
tree | a5f5e0086a2da8c4bb333efc7e53c42996ecdfff /src/script/standard.h | |
parent | 49487bc3b6038393c1b9c2dbdc04a78ae1178f1a (diff) | |
download | bitcoin-a2380127e905e5849f90acc7c69832859d8336aa.tar.xz |
Basic Taproot signing logic in script/sign.cpp
Diffstat (limited to 'src/script/standard.h')
-rw-r--r-- | src/script/standard.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/script/standard.h b/src/script/standard.h index 8db17b2779..285dd4c116 100644 --- a/src/script/standard.h +++ b/src/script/standard.h @@ -210,14 +210,26 @@ CScript GetScriptForRawPubKey(const CPubKey& pubkey); /** Generate a multisig script. */ CScript GetScriptForMultisig(int nRequired, const std::vector<CPubKey>& keys); +struct ShortestVectorFirstComparator +{ + bool operator()(const std::vector<unsigned char>& a, const std::vector<unsigned char>& b) const + { + if (a.size() < b.size()) return true; + if (a.size() > b.size()) return false; + return a < b; + } +}; + struct TaprootSpendData { /** The BIP341 internal key. */ XOnlyPubKey internal_key; /** The Merkle root of the script tree (0 if no scripts). */ uint256 merkle_root; - /** Map from (script, leaf_version) to (sets of) control blocks. */ - std::map<std::pair<CScript, int>, std::set<std::vector<unsigned char>>> scripts; + /** Map from (script, leaf_version) to (sets of) control blocks. + * The control blocks are sorted by size, so that the signing logic can + * easily prefer the cheapest one. */ + std::map<std::pair<CScript, int>, std::set<std::vector<unsigned char>, ShortestVectorFirstComparator>> scripts; /** Merge other TaprootSpendData (for the same scriptPubKey) into this. */ void Merge(TaprootSpendData other); }; |