Skip to content

Commit 5b44a75

Browse files
committed
refactor: Remove unused CExt{Pub,}Key (de)serialization methods
The serialization/deserialization methods for the classes CExtKey and CExtPubKey were only used in the BIP32 unit tests, where the relevant parts are removed as well.
1 parent a22b624 commit 5b44a75

File tree

3 files changed

+0
-60
lines changed

3 files changed

+0
-60
lines changed

src/key.h

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

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

src/pubkey.h

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -222,31 +222,6 @@ struct CExtPubKey {
222222
void Encode(unsigned char code[BIP32_EXTKEY_SIZE]) const;
223223
void Decode(const unsigned char code[BIP32_EXTKEY_SIZE]);
224224
bool Derive(CExtPubKey& out, unsigned int nChild) const;
225-
226-
void Serialize(CSizeComputer& s) const
227-
{
228-
// Optimized implementation for ::GetSerializeSize that avoids copying.
229-
s.seek(BIP32_EXTKEY_SIZE + 1); // add one byte for the size (compact int)
230-
}
231-
template <typename Stream>
232-
void Serialize(Stream& s) const
233-
{
234-
unsigned int len = BIP32_EXTKEY_SIZE;
235-
::WriteCompactSize(s, len);
236-
unsigned char code[BIP32_EXTKEY_SIZE];
237-
Encode(code);
238-
s.write((const char *)&code[0], len);
239-
}
240-
template <typename Stream>
241-
void Unserialize(Stream& s)
242-
{
243-
unsigned int len = ::ReadCompactSize(s);
244-
unsigned char code[BIP32_EXTKEY_SIZE];
245-
if (len != BIP32_EXTKEY_SIZE)
246-
throw std::runtime_error("Invalid extended key size\n");
247-
s.read((char *)&code[0], len);
248-
Decode(code);
249-
}
250225
};
251226

252227
/** Users of this module must hold an ECCVerifyHandle. The constructor and

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)