Skip to content

Commit fe28408

Browse files
MarcoFalkeknst
authored andcommitted
partial Merge bitcoin#17212: refactor: Remove unused CExt{Pub,}Key (de)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
1 parent 8835cbe commit fe28408

File tree

2 files changed

+0
-35
lines changed

2 files changed

+0
-35
lines changed

src/key.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -161,25 +161,6 @@ struct CExtKey {
161161
bool Derive(CExtKey& out, unsigned int nChild) const;
162162
CExtPubKey Neuter() const;
163163
void SetSeed(const unsigned char* seed, unsigned int nSeedLen);
164-
template <typename Stream>
165-
void Serialize(Stream& s) const
166-
{
167-
unsigned int len = BIP32_EXTKEY_SIZE;
168-
::WriteCompactSize(s, len);
169-
unsigned char code[BIP32_EXTKEY_SIZE];
170-
Encode(code);
171-
s.write((const char *)&code[0], len);
172-
}
173-
template <typename Stream>
174-
void Unserialize(Stream& s)
175-
{
176-
unsigned int len = ::ReadCompactSize(s);
177-
unsigned char code[BIP32_EXTKEY_SIZE];
178-
if (len != BIP32_EXTKEY_SIZE)
179-
throw std::runtime_error("Invalid extended key size\n");
180-
s.read((char *)&code[0], len);
181-
Decode(code);
182-
}
183164
};
184165

185166
/** Initialize the elliptic curve support. May not be called twice without calling ECC_Stop first. */

src/test/bip32_tests.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -118,22 +118,6 @@ static void RunTest(const TestVector &test) {
118118
}
119119
key = keyNew;
120120
pubkey = pubkeyNew;
121-
122-
CDataStream ssPub(SER_DISK, CLIENT_VERSION);
123-
ssPub << pubkeyNew;
124-
BOOST_CHECK(ssPub.size() == 75);
125-
126-
CDataStream ssPriv(SER_DISK, CLIENT_VERSION);
127-
ssPriv << keyNew;
128-
BOOST_CHECK(ssPriv.size() == 75);
129-
130-
CExtPubKey pubCheck;
131-
CExtKey privCheck;
132-
ssPub >> pubCheck;
133-
ssPriv >> privCheck;
134-
135-
BOOST_CHECK(pubCheck == pubkeyNew);
136-
BOOST_CHECK(privCheck == keyNew);
137121
}
138122
}
139123

0 commit comments

Comments
 (0)