Skip to content

Commit 141861e

Browse files
PastaPastaPastalaanwjUdjinM6codablock
committed
Merge bitcoin#11117: Prepare for non-Base58 addresses (#3294)
* Merge bitcoin#11117: Prepare for non-Base58 addresses 864cd27 Move CBitcoinAddress to base58.cpp (Pieter Wuille) 5c8ff0d Introduce wrappers around CBitcoinAddress (Pieter Wuille) Pull request description: This patch removes the need for the intermediary Base58 type `CBitcoinAddress`, by providing {`Encode`,`Decode`,`IsValid`}`Destination` functions that directly operate on the conversion between `std::string`s and `CTxDestination`. As a side, it also fixes a number of indentation issues, and removes probably several unnecessary implicit `CTxDestination`<->`CBitcoinAddress` conversions. This change is far from complete. In follow-ups I'd like to: * Split off the specific address and key encoding logic from base58.h, and move it to a address.h or so. * Replace `CTxDestination` with a non-`boost::variant` version (which can be more efficient as `boost::variant` allocates everything on the heap, and remove the need for `boost::get<...>` and `IsValidDestination` calls everywhere). * Do the same for `CBitcoinSecret`, `CBitcoinExtKey`, and `CBitcoinExtPubKey`. However, I've tried to keep this patch to be minimally invasive, but still enough to support non-Base58 addresses. Perhaps a smaller patch is possible to hack Bech32 support into `CBitcoinAddress`, but I would consider that a move in the wrong direction. Tree-SHA512: c2c77ffb57caeadf2429b1c2562ce60e8c7be8aa9f8e51b591f354b6b441162625b2efe14c023a1ae485cf2ed417263afa35c892891dfaa7844e7fbabccab85e * CBitcoinAddress -> EncodeDestination in providertx.h Signed-off-by: Pasta <pasta@dashboost.org> * more CBitcoinAddress -> EncodeDestination in providertx.h Signed-off-by: Pasta <pasta@dashboost.org> * more CBitcoinAddress -> EncodeDestination in providertx.h Signed-off-by: Pasta <pasta@dashboost.org> * more CBitcoinAddress -> EncodeDestination in providertx.h Signed-off-by: Pasta <pasta@dashboost.org> * fix CBitcoinAddress GetKeyID check Signed-off-by: Pasta <pasta@dashboost.org> * fix providertx.cpp Signed-off-by: Pasta <pasta@dashboost.org> * hopefully fix governance-classes.cpp Signed-off-by: Pasta <pasta@dashboost.org> * partially fix governance-validators.cpp, unable to resolve "address.IsScript()" Signed-off-by: Pasta <pasta@dashboost.org> * partially fix governance-classes.cpp, unable to resolve "address.IsScript()" Signed-off-by: Pasta <pasta@dashboost.org> * fix governance-classes.h Signed-off-by: Pasta <pasta@dashboost.org> * DecodeTransaction -> DecodeDestination, fix governance-validators.cpp Signed-off-by: Pasta <pasta@dashboost.org> * More fixes for 3294 * Move GetIndexKey into rpc/misc.cpp near getAddressesFromParams No need to have it in base58.cpp anymore as this is only used in getAddressesFromParams Co-authored-by: Wladimir J. van der Laan <laanwj@gmail.com> Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com> Co-authored-by: Alexander Block <ablock84@gmail.com>
1 parent 39a524d commit 141861e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+493
-507
lines changed

src/base58.cpp

Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,29 @@ int CBase58Data::CompareTo(const CBase58Data& b58) const
212212

213213
namespace
214214
{
215+
/** base58-encoded Bitcoin addresses.
216+
* Public-key-hash-addresses have version 0 (or 111 testnet).
217+
* The data vector contains RIPEMD160(SHA256(pubkey)), where pubkey is the serialized public key.
218+
* Script-hash-addresses have version 5 (or 196 testnet).
219+
* The data vector contains RIPEMD160(SHA256(cscript)), where cscript is the serialized redemption script.
220+
*/
221+
class CBitcoinAddress : public CBase58Data {
222+
public:
223+
bool Set(const CKeyID &id);
224+
bool Set(const CScriptID &id);
225+
bool Set(const CTxDestination &dest);
226+
bool IsValid() const;
227+
bool IsValid(const CChainParams &params) const;
228+
229+
CBitcoinAddress() {}
230+
CBitcoinAddress(const CTxDestination &dest) { Set(dest); }
231+
CBitcoinAddress(const std::string& strAddress) { SetString(strAddress); }
232+
CBitcoinAddress(const char* pszAddress) { SetString(pszAddress); }
233+
234+
CTxDestination Get() const;
235+
bool GetKeyID(CKeyID &keyID) const;
236+
};
237+
215238
class CBitcoinAddressVisitor : public boost::static_visitor<bool>
216239
{
217240
private:
@@ -271,23 +294,6 @@ CTxDestination CBitcoinAddress::Get() const
271294
return CNoDestination();
272295
}
273296

274-
bool CBitcoinAddress::GetIndexKey(uint160& hashBytes, int& type) const
275-
{
276-
if (!IsValid()) {
277-
return false;
278-
} else if (vchVersion == Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS)) {
279-
memcpy(&hashBytes, vchData.data(), 20);
280-
type = 1;
281-
return true;
282-
} else if (vchVersion == Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS)) {
283-
memcpy(&hashBytes, vchData.data(), 20);
284-
type = 2;
285-
return true;
286-
}
287-
288-
return false;
289-
}
290-
291297
bool CBitcoinAddress::GetKeyID(CKeyID& keyID) const
292298
{
293299
if (!IsValid() || vchVersion != Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS))
@@ -298,11 +304,6 @@ bool CBitcoinAddress::GetKeyID(CKeyID& keyID) const
298304
return true;
299305
}
300306

301-
bool CBitcoinAddress::IsScript() const
302-
{
303-
return IsValid() && vchVersion == Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS);
304-
}
305-
306307
void CBitcoinSecret::SetKey(const CKey& vchSecret)
307308
{
308309
assert(vchSecret.IsValid());
@@ -335,3 +336,26 @@ bool CBitcoinSecret::SetString(const std::string& strSecret)
335336
{
336337
return SetString(strSecret.c_str());
337338
}
339+
340+
std::string EncodeDestination(const CTxDestination& dest)
341+
{
342+
CBitcoinAddress addr(dest);
343+
if (!addr.IsValid()) return "";
344+
return addr.ToString();
345+
}
346+
347+
CTxDestination DecodeDestination(const std::string& str)
348+
{
349+
return CBitcoinAddress(str).Get();
350+
}
351+
352+
bool IsValidDestinationString(const std::string& str, const CChainParams& params)
353+
{
354+
return CBitcoinAddress(str).IsValid(params);
355+
}
356+
357+
bool IsValidDestinationString(const std::string& str)
358+
{
359+
return CBitcoinAddress(str).IsValid();
360+
}
361+

src/base58.h

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -95,31 +95,6 @@ class CBase58Data
9595
bool operator> (const CBase58Data& b58) const { return CompareTo(b58) > 0; }
9696
};
9797

98-
/** base58-encoded Dash addresses.
99-
* Public-key-hash-addresses have version 76 (or 140 testnet).
100-
* The data vector contains RIPEMD160(SHA256(pubkey)), where pubkey is the serialized public key.
101-
* Script-hash-addresses have version 16 (or 19 testnet).
102-
* The data vector contains RIPEMD160(SHA256(cscript)), where cscript is the serialized redemption script.
103-
*/
104-
class CBitcoinAddress : public CBase58Data {
105-
public:
106-
bool Set(const CKeyID &id);
107-
bool Set(const CScriptID &id);
108-
bool Set(const CTxDestination &dest);
109-
bool IsValid() const;
110-
bool IsValid(const CChainParams &params) const;
111-
112-
CBitcoinAddress() {}
113-
CBitcoinAddress(const CTxDestination &dest) { Set(dest); }
114-
CBitcoinAddress(const std::string& strAddress) { SetString(strAddress); }
115-
CBitcoinAddress(const char* pszAddress) { SetString(pszAddress); }
116-
117-
CTxDestination Get() const;
118-
bool GetKeyID(CKeyID &keyID) const;
119-
bool GetIndexKey(uint160& hashBytes, int& type) const;
120-
bool IsScript() const;
121-
};
122-
12398
/**
12499
* A base58-encoded secret key
125100
*/
@@ -168,4 +143,9 @@ template<typename K, int Size, CChainParams::Base58Type Type> class CBitcoinExtK
168143
typedef CBitcoinExtKeyBase<CExtKey, BIP32_EXTKEY_SIZE, CChainParams::EXT_SECRET_KEY> CBitcoinExtKey;
169144
typedef CBitcoinExtKeyBase<CExtPubKey, BIP32_EXTKEY_SIZE, CChainParams::EXT_PUBLIC_KEY> CBitcoinExtPubKey;
170145

146+
std::string EncodeDestination(const CTxDestination& dest);
147+
CTxDestination DecodeDestination(const std::string& str);
148+
bool IsValidDestinationString(const std::string& str);
149+
bool IsValidDestinationString(const std::string& str, const CChainParams& params);
150+
171151
#endif // BITCOIN_BASE58_H

src/core_write.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,9 @@ void ScriptPubKeyToUniv(const CScript& scriptPubKey,
154154
out.pushKV("type", GetTxnOutputType(type));
155155

156156
UniValue a(UniValue::VARR);
157-
for (const CTxDestination& addr : addresses)
158-
a.push_back(CBitcoinAddress(addr).ToString());
157+
for (const CTxDestination& addr : addresses) {
158+
a.push_back(EncodeDestination(addr));
159+
}
159160
out.pushKV("addresses", a);
160161
}
161162

@@ -190,9 +191,9 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry,
190191
in.push_back(Pair("value", ValueFromAmount(spentInfo.satoshis)));
191192
in.push_back(Pair("valueSat", spentInfo.satoshis));
192193
if (spentInfo.addressType == 1) {
193-
in.push_back(Pair("address", CBitcoinAddress(CKeyID(spentInfo.addressHash)).ToString()));
194+
in.push_back(Pair("address", EncodeDestination(CKeyID(spentInfo.addressHash))));
194195
} else if (spentInfo.addressType == 2) {
195-
in.push_back(Pair("address", CBitcoinAddress(CScriptID(spentInfo.addressHash)).ToString()));
196+
in.push_back(Pair("address", EncodeDestination(CScriptID(spentInfo.addressHash))));
196197
}
197198
}
198199
}

src/dash-tx.cpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,11 @@ static void MutateTxAddOutAddr(CMutableTransaction& tx, const std::string& strIn
253253

254254
// extract and validate ADDRESS
255255
std::string strAddr = vStrInputParts[1];
256-
CBitcoinAddress addr(strAddr);
257-
if (!addr.IsValid())
256+
CTxDestination destination = DecodeDestination(strAddr);
257+
if (!IsValidDestination(destination)) {
258258
throw std::runtime_error("invalid TX output address");
259-
// build standard output script via GetScriptForDestination()
260-
CScript scriptPubKey = GetScriptForDestination(addr.Get());
259+
}
260+
CScript scriptPubKey = GetScriptForDestination(destination);
261261

262262
// construct TxOut, append to transaction output list
263263
CTxOut txout(value, scriptPubKey);
@@ -290,10 +290,8 @@ static void MutateTxAddOutPubKey(CMutableTransaction& tx, const std::string& str
290290
}
291291

292292
if (bScriptHash) {
293-
// Get the address for the redeem script, then call
294-
// GetScriptForDestination() to construct a P2SH scriptPubKey.
295-
CBitcoinAddress redeemScriptAddr(scriptPubKey);
296-
scriptPubKey = GetScriptForDestination(redeemScriptAddr.Get());
293+
// Get the ID for the script, and then construct a P2SH destination for it.
294+
scriptPubKey = GetScriptForDestination(CScriptID(scriptPubKey));
297295
}
298296

299297
// construct TxOut, append to transaction output list
@@ -355,9 +353,8 @@ static void MutateTxAddOutMultiSig(CMutableTransaction& tx, const std::string& s
355353
throw std::runtime_error(strprintf(
356354
"redeemScript exceeds size limit: %d > %d", scriptPubKey.size(), MAX_SCRIPT_ELEMENT_SIZE));
357355
}
358-
// GetScriptForDestination() to construct a P2SH scriptPubKey.
359-
CBitcoinAddress addr(scriptPubKey);
360-
scriptPubKey = GetScriptForDestination(addr.Get());
356+
// Get the ID for the script, and then construct a P2SH destination for it.
357+
scriptPubKey = GetScriptForDestination(CScriptID(scriptPubKey));
361358
}
362359

363360
// construct TxOut, append to transaction output list
@@ -424,8 +421,7 @@ static void MutateTxAddOutScript(CMutableTransaction& tx, const std::string& str
424421
throw std::runtime_error(strprintf(
425422
"redeemScript exceeds size limit: %d > %d", scriptPubKey.size(), MAX_SCRIPT_ELEMENT_SIZE));
426423
}
427-
CBitcoinAddress addr(scriptPubKey);
428-
scriptPubKey = GetScriptForDestination(addr.Get());
424+
scriptPubKey = GetScriptForDestination(CScriptID(scriptPubKey));
429425
}
430426

431427
// construct TxOut, append to transaction output list

src/evo/deterministicmns.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ std::string CDeterministicMNState::ToString() const
2929
std::string payoutAddress = "unknown";
3030
std::string operatorPayoutAddress = "none";
3131
if (ExtractDestination(scriptPayout, dest)) {
32-
payoutAddress = CBitcoinAddress(dest).ToString();
32+
payoutAddress = EncodeDestination(dest);
3333
}
3434
if (ExtractDestination(scriptOperatorPayout, dest)) {
35-
operatorPayoutAddress = CBitcoinAddress(dest).ToString();
35+
operatorPayoutAddress = EncodeDestination(dest);
3636
}
3737

3838
return strprintf("CDeterministicMNState(nRegisteredHeight=%d, nLastPaidHeight=%d, nPoSePenalty=%d, nPoSeRevivedHeight=%d, nPoSeBanHeight=%d, nRevocationReason=%d, "
3939
"ownerAddress=%s, pubKeyOperator=%s, votingAddress=%s, addr=%s, payoutAddress=%s, operatorPayoutAddress=%s)",
4040
nRegisteredHeight, nLastPaidHeight, nPoSePenalty, nPoSeRevivedHeight, nPoSeBanHeight, nRevocationReason,
41-
CBitcoinAddress(keyIDOwner).ToString(), pubKeyOperator.Get().ToString(), CBitcoinAddress(keyIDVoting).ToString(), addr.ToStringIPPort(false), payoutAddress, operatorPayoutAddress);
41+
EncodeDestination(keyIDOwner), pubKeyOperator.Get().ToString(), EncodeDestination(keyIDVoting), addr.ToStringIPPort(false), payoutAddress, operatorPayoutAddress);
4242
}
4343

4444
void CDeterministicMNState::ToJson(UniValue& obj) const
@@ -52,18 +52,16 @@ void CDeterministicMNState::ToJson(UniValue& obj) const
5252
obj.push_back(Pair("PoSeRevivedHeight", nPoSeRevivedHeight));
5353
obj.push_back(Pair("PoSeBanHeight", nPoSeBanHeight));
5454
obj.push_back(Pair("revocationReason", nRevocationReason));
55-
obj.push_back(Pair("ownerAddress", CBitcoinAddress(keyIDOwner).ToString()));
56-
obj.push_back(Pair("votingAddress", CBitcoinAddress(keyIDVoting).ToString()));
55+
obj.push_back(Pair("ownerAddress", EncodeDestination(keyIDOwner)));
56+
obj.push_back(Pair("votingAddress", EncodeDestination(keyIDVoting)));
5757

5858
CTxDestination dest;
5959
if (ExtractDestination(scriptPayout, dest)) {
60-
CBitcoinAddress payoutAddress(dest);
61-
obj.push_back(Pair("payoutAddress", payoutAddress.ToString()));
60+
obj.push_back(Pair("payoutAddress", EncodeDestination(dest)));
6261
}
6362
obj.push_back(Pair("pubKeyOperator", pubKeyOperator.Get().ToString()));
6463
if (ExtractDestination(scriptOperatorPayout, dest)) {
65-
CBitcoinAddress operatorPayoutAddress(dest);
66-
obj.push_back(Pair("operatorPayoutAddress", operatorPayoutAddress.ToString()));
64+
obj.push_back(Pair("operatorPayoutAddress", EncodeDestination(dest)));
6765
}
6866
}
6967

@@ -88,7 +86,7 @@ void CDeterministicMN::ToJson(UniValue& obj) const
8886
if (GetUTXOCoin(collateralOutpoint, coin)) {
8987
CTxDestination dest;
9088
if (ExtractDestination(coin.out.scriptPubKey, dest)) {
91-
obj.push_back(Pair("collateralAddress", CBitcoinAddress(dest).ToString()));
89+
obj.push_back(Pair("collateralAddress", EncodeDestination(dest)));
9290
}
9391
}
9492

src/evo/providertx.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ bool CheckProRegTx(const CTransaction& tx, const CBlockIndex* pindexPrev, CValid
132132
}
133133

134134
CTxDestination collateralTxDest;
135-
CKeyID keyForPayloadSig;
135+
const CKeyID *keyForPayloadSig = nullptr;
136136
COutPoint collateralOutpoint;
137137

138138
if (!ptx.collateralOutpoint.hash.IsNull()) {
@@ -147,7 +147,8 @@ bool CheckProRegTx(const CTransaction& tx, const CBlockIndex* pindexPrev, CValid
147147

148148
// Extract key from collateral. This only works for P2PK and P2PKH collaterals and will fail for P2SH.
149149
// Issuer of this ProRegTx must prove ownership with this key by signing the ProRegTx
150-
if (!CBitcoinAddress(collateralTxDest).GetKeyID(keyForPayloadSig)) {
150+
keyForPayloadSig = boost::get<CKeyID>(&collateralTxDest);
151+
if (!keyForPayloadSig) {
151152
return state.DoS(10, false, REJECT_INVALID, "bad-protx-collateral-pkh");
152153
}
153154

@@ -197,9 +198,9 @@ bool CheckProRegTx(const CTransaction& tx, const CBlockIndex* pindexPrev, CValid
197198
return false;
198199
}
199200

200-
if (!keyForPayloadSig.IsNull()) {
201+
if (keyForPayloadSig) {
201202
// collateral is not part of this ProRegTx, so we must verify ownership of the collateral
202-
if (!CheckStringSig(ptx, keyForPayloadSig, state)) {
203+
if (!CheckStringSig(ptx, *keyForPayloadSig, state)) {
203204
return false;
204205
}
205206
} else {
@@ -390,18 +391,17 @@ std::string CProRegTx::MakeSignString() const
390391
// We only include the important stuff in the string form...
391392

392393
CTxDestination destPayout;
393-
CBitcoinAddress addrPayout;
394394
std::string strPayout;
395-
if (ExtractDestination(scriptPayout, destPayout) && addrPayout.Set(destPayout)) {
396-
strPayout = addrPayout.ToString();
395+
if (ExtractDestination(scriptPayout, destPayout)) {
396+
strPayout = EncodeDestination(destPayout);
397397
} else {
398398
strPayout = HexStr(scriptPayout.begin(), scriptPayout.end());
399399
}
400400

401401
s += strPayout + "|";
402402
s += strprintf("%d", nOperatorReward) + "|";
403-
s += CBitcoinAddress(keyIDOwner).ToString() + "|";
404-
s += CBitcoinAddress(keyIDVoting).ToString() + "|";
403+
s += EncodeDestination(keyIDOwner) + "|";
404+
s += EncodeDestination(keyIDVoting) + "|";
405405

406406
// ... and also the full hash of the payload as a protection agains malleability and replays
407407
s += ::SerializeHash(*this).ToString();
@@ -414,19 +414,19 @@ std::string CProRegTx::ToString() const
414414
CTxDestination dest;
415415
std::string payee = "unknown";
416416
if (ExtractDestination(scriptPayout, dest)) {
417-
payee = CBitcoinAddress(dest).ToString();
417+
payee = EncodeDestination(dest);
418418
}
419419

420420
return strprintf("CProRegTx(nVersion=%d, collateralOutpoint=%s, addr=%s, nOperatorReward=%f, ownerAddress=%s, pubKeyOperator=%s, votingAddress=%s, scriptPayout=%s)",
421-
nVersion, collateralOutpoint.ToStringShort(), addr.ToString(), (double)nOperatorReward / 100, CBitcoinAddress(keyIDOwner).ToString(), pubKeyOperator.ToString(), CBitcoinAddress(keyIDVoting).ToString(), payee);
421+
nVersion, collateralOutpoint.ToStringShort(), addr.ToString(), (double)nOperatorReward / 100, EncodeDestination(keyIDOwner), pubKeyOperator.ToString(), EncodeDestination(keyIDVoting), payee);
422422
}
423423

424424
std::string CProUpServTx::ToString() const
425425
{
426426
CTxDestination dest;
427427
std::string payee = "unknown";
428428
if (ExtractDestination(scriptOperatorPayout, dest)) {
429-
payee = CBitcoinAddress(dest).ToString();
429+
payee = EncodeDestination(dest);
430430
}
431431

432432
return strprintf("CProUpServTx(nVersion=%d, proTxHash=%s, addr=%s, operatorPayoutAddress=%s)",
@@ -438,11 +438,11 @@ std::string CProUpRegTx::ToString() const
438438
CTxDestination dest;
439439
std::string payee = "unknown";
440440
if (ExtractDestination(scriptPayout, dest)) {
441-
payee = CBitcoinAddress(dest).ToString();
441+
payee = EncodeDestination(dest);
442442
}
443443

444444
return strprintf("CProUpRegTx(nVersion=%d, proTxHash=%s, pubKeyOperator=%s, votingAddress=%s, payoutAddress=%s)",
445-
nVersion, proTxHash.ToString(), pubKeyOperator.ToString(), CBitcoinAddress(keyIDVoting).ToString(), payee);
445+
nVersion, proTxHash.ToString(), pubKeyOperator.ToString(), EncodeDestination(keyIDVoting), payee);
446446
}
447447

448448
std::string CProUpRevTx::ToString() const

src/evo/providertx.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,12 @@ class CProRegTx
7171
obj.push_back(Pair("collateralHash", collateralOutpoint.hash.ToString()));
7272
obj.push_back(Pair("collateralIndex", (int)collateralOutpoint.n));
7373
obj.push_back(Pair("service", addr.ToString(false)));
74-
obj.push_back(Pair("ownerAddress", CBitcoinAddress(keyIDOwner).ToString()));
75-
obj.push_back(Pair("votingAddress", CBitcoinAddress(keyIDVoting).ToString()));
74+
obj.push_back(Pair("ownerAddress", EncodeDestination(keyIDOwner)));
75+
obj.push_back(Pair("votingAddress", EncodeDestination(keyIDVoting)));
7676

7777
CTxDestination dest;
7878
if (ExtractDestination(scriptPayout, dest)) {
79-
CBitcoinAddress bitcoinAddress(dest);
80-
obj.push_back(Pair("payoutAddress", bitcoinAddress.ToString()));
79+
obj.push_back(Pair("payoutAddress", EncodeDestination(dest)));
8180
}
8281
obj.push_back(Pair("pubKeyOperator", pubKeyOperator.ToString()));
8382
obj.push_back(Pair("operatorReward", (double)nOperatorReward / 100));
@@ -127,8 +126,7 @@ class CProUpServTx
127126
obj.push_back(Pair("service", addr.ToString(false)));
128127
CTxDestination dest;
129128
if (ExtractDestination(scriptOperatorPayout, dest)) {
130-
CBitcoinAddress bitcoinAddress(dest);
131-
obj.push_back(Pair("operatorPayoutAddress", bitcoinAddress.ToString()));
129+
obj.push_back(Pair("operatorPayoutAddress", EncodeDestination(dest)));
132130
}
133131
obj.push_back(Pair("inputsHash", inputsHash.ToString()));
134132
}
@@ -176,11 +174,10 @@ class CProUpRegTx
176174
obj.setObject();
177175
obj.push_back(Pair("version", nVersion));
178176
obj.push_back(Pair("proTxHash", proTxHash.ToString()));
179-
obj.push_back(Pair("votingAddress", CBitcoinAddress(keyIDVoting).ToString()));
177+
obj.push_back(Pair("votingAddress", EncodeDestination(keyIDVoting)));
180178
CTxDestination dest;
181179
if (ExtractDestination(scriptPayout, dest)) {
182-
CBitcoinAddress bitcoinAddress(dest);
183-
obj.push_back(Pair("payoutAddress", bitcoinAddress.ToString()));
180+
obj.push_back(Pair("payoutAddress", EncodeDestination(dest)));
184181
}
185182
obj.push_back(Pair("pubKeyOperator", pubKeyOperator.ToString()));
186183
obj.push_back(Pair("inputsHash", inputsHash.ToString()));

0 commit comments

Comments
 (0)