Skip to content

Commit

Permalink
partial Merge bitcoin#17212: refactor: Remove unused CExt{Pub,}Key (d…
Browse files Browse the repository at this point in the history
…e)serialization methods

5b44a75 refactor: Remove unused CExt{Pub,}Key (de)serialization methods (Sebastian Falbesoner)

Pull request description:

  As pointed out in issue bitcoin#17130, the serialization/deserialization methods for the classes `CExtKey` and
  `CExtPubKey` are only used in the BIP32 unit tests and hence can be removed (see comments bitcoin#17130 (comment), bitcoin#17130 (comment) and bitcoin#17130 (comment)).

ACKs for top commit:
  practicalswift:
    ACK 5b44a75 -- -60 LOC diff looks correct :)
  promag:
    ACK 5b44a75.
  MarcoFalke:
    unsigned ACK 5b44a75
  fjahr:
    ACK 5b44a75
  jonatack:
    Light ACK 5b44a75. Built, ran tests and bitcoind. `git blame` shows most of the last changes are from commit 90604f1 in 2015 to add bip32 pubkey serialization.

Tree-SHA512: 6887573b76b9e54e117a076557407b6f7908719b2202fb9eea498522baf9f30198b3f78b87a62efcd17ad1ab0886196f099239992ce7cbbaee79979ffe9e5f2c
  • Loading branch information
MarcoFalke authored and knst committed Apr 10, 2023
1 parent 36599db commit 256ab15
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 35 deletions.
19 changes: 0 additions & 19 deletions src/key.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,25 +161,6 @@ struct CExtKey {
bool Derive(CExtKey& out, unsigned int nChild) const;
CExtPubKey Neuter() const;
void SetSeed(const unsigned char* seed, unsigned int nSeedLen);
template <typename Stream>
void Serialize(Stream& s) const
{
unsigned int len = BIP32_EXTKEY_SIZE;
::WriteCompactSize(s, len);
unsigned char code[BIP32_EXTKEY_SIZE];
Encode(code);
s.write((const char *)&code[0], len);
}
template <typename Stream>
void Unserialize(Stream& s)
{
unsigned int len = ::ReadCompactSize(s);
unsigned char code[BIP32_EXTKEY_SIZE];
if (len != BIP32_EXTKEY_SIZE)
throw std::runtime_error("Invalid extended key size\n");
s.read((char *)&code[0], len);
Decode(code);
}
};

/** Initialize the elliptic curve support. May not be called twice without calling ECC_Stop first. */
Expand Down
16 changes: 0 additions & 16 deletions src/test/bip32_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,22 +118,6 @@ static void RunTest(const TestVector &test) {
}
key = keyNew;
pubkey = pubkeyNew;

CDataStream ssPub(SER_DISK, CLIENT_VERSION);
ssPub << pubkeyNew;
BOOST_CHECK(ssPub.size() == 75);

CDataStream ssPriv(SER_DISK, CLIENT_VERSION);
ssPriv << keyNew;
BOOST_CHECK(ssPriv.size() == 75);

CExtPubKey pubCheck;
CExtKey privCheck;
ssPub >> pubCheck;
ssPriv >> privCheck;

BOOST_CHECK(pubCheck == pubkeyNew);
BOOST_CHECK(privCheck == keyNew);
}
}

Expand Down

0 comments on commit 256ab15

Please sign in to comment.