Skip to content

Commit fae76a1

Browse files
author
MarcoFalke
committed
scripted-diff: Use DataStream in most places
The remaining places are handled easier outside a scripted-diff. -BEGIN VERIFY SCRIPT- sed --regexp-extended -i 's/CDataStream ([0-9a-zA-Z_]+)\(SER_[A-Z]+, [A-Z_]+_VERSION\);/DataStream \1{};/g' $( git grep -l CDataStream) sed -i 's/, CDataStream/, DataStream/g' src/wallet/walletdb.cpp -END VERIFY SCRIPT-
1 parent fac39b5 commit fae76a1

12 files changed

+53
-53
lines changed

src/external_signer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ UniValue ExternalSigner::GetDescriptors(const int account)
7474
bool ExternalSigner::SignTransaction(PartiallySignedTransaction& psbtx, std::string& error)
7575
{
7676
// Serialize the PSBT
77-
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
77+
DataStream ssTx{};
7878
ssTx << psbtx;
7979
// parse ExternalSigner master fingerprint
8080
std::vector<unsigned char> parsed_m_fingerprint = ParseHex(m_fingerprint);

src/qt/psbtoperationsdialog.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,14 @@ void PSBTOperationsDialog::broadcastTransaction()
128128
}
129129

130130
void PSBTOperationsDialog::copyToClipboard() {
131-
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
131+
DataStream ssTx{};
132132
ssTx << m_transaction_data;
133133
GUIUtil::setClipboard(EncodeBase64(ssTx.str()).c_str());
134134
showStatus(tr("PSBT copied to clipboard."), StatusLevel::INFO);
135135
}
136136

137137
void PSBTOperationsDialog::saveTransaction() {
138-
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
138+
DataStream ssTx{};
139139
ssTx << m_transaction_data;
140140

141141
QString selected_filter;

src/qt/sendcoinsdialog.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ bool SendCoinsDialog::PrepareSendText(QString& question_string, QString& informa
397397
void SendCoinsDialog::presentPSBT(PartiallySignedTransaction& psbtx)
398398
{
399399
// Serialize the PSBT
400-
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
400+
DataStream ssTx{};
401401
ssTx << psbtx;
402402
GUIUtil::setClipboard(EncodeBase64(ssTx.str()).c_str());
403403
QMessageBox msgBox(this);

src/qt/walletmodel.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ bool WalletModel::bumpFee(uint256 hash, uint256& new_hash)
543543
return false;
544544
}
545545
// Serialize the PSBT
546-
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
546+
DataStream ssTx{};
547547
ssTx << psbtx;
548548
GUIUtil::setClipboard(EncodeBase64(ssTx.str()).c_str());
549549
Q_EMIT message(tr("PSBT copied"), tr("Copied to clipboard", "Fee-bump PSBT saved"), CClientUIInterface::MSG_INFORMATION);

src/rpc/rawtransaction.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -1493,7 +1493,7 @@ static RPCHelpMan combinepsbt()
14931493
throw JSONRPCTransactionError(error);
14941494
}
14951495

1496-
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
1496+
DataStream ssTx{};
14971497
ssTx << merged_psbt;
14981498
return EncodeBase64(ssTx);
14991499
},
@@ -1538,7 +1538,7 @@ static RPCHelpMan finalizepsbt()
15381538
bool complete = FinalizeAndExtractPSBT(psbtx, mtx);
15391539

15401540
UniValue result(UniValue::VOBJ);
1541-
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
1541+
DataStream ssTx{};
15421542
std::string result_str;
15431543

15441544
if (complete && extract) {
@@ -1589,7 +1589,7 @@ static RPCHelpMan createpsbt()
15891589
}
15901590

15911591
// Serialize the PSBT
1592-
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
1592+
DataStream ssTx{};
15931593
ssTx << psbtx;
15941594

15951595
return EncodeBase64(ssTx);
@@ -1656,7 +1656,7 @@ static RPCHelpMan converttopsbt()
16561656
}
16571657

16581658
// Serialize the PSBT
1659-
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
1659+
DataStream ssTx{};
16601660
ssTx << psbtx;
16611661

16621662
return EncodeBase64(ssTx);
@@ -1703,7 +1703,7 @@ static RPCHelpMan utxoupdatepsbt()
17031703
/*sighash_type=*/SIGHASH_ALL,
17041704
/*finalize=*/false);
17051705

1706-
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
1706+
DataStream ssTx{};
17071707
ssTx << psbtx;
17081708
return EncodeBase64(ssTx);
17091709
},
@@ -1804,7 +1804,7 @@ static RPCHelpMan joinpsbts()
18041804
}
18051805
shuffled_psbt.unknown.insert(merged_psbt.unknown.begin(), merged_psbt.unknown.end());
18061806

1807-
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
1807+
DataStream ssTx{};
18081808
ssTx << shuffled_psbt;
18091809
return EncodeBase64(ssTx);
18101810
},
@@ -1984,7 +1984,7 @@ RPCHelpMan descriptorprocesspsbt()
19841984
complete &= PSBTInputSigned(input);
19851985
}
19861986

1987-
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
1987+
DataStream ssTx{};
19881988
ssTx << psbtx;
19891989

19901990
UniValue result(UniValue::VOBJ);

src/test/blockencodings_tests.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE(SimpleRoundTripTest)
6868
{
6969
CBlockHeaderAndShortTxIDs shortIDs{block};
7070

71-
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
71+
DataStream stream{};
7272
stream << shortIDs;
7373

7474
CBlockHeaderAndShortTxIDs shortIDs2;
@@ -119,15 +119,15 @@ class TestHeaderAndShortIDs {
119119
std::vector<PrefilledTransaction> prefilledtxn;
120120

121121
explicit TestHeaderAndShortIDs(const CBlockHeaderAndShortTxIDs& orig) {
122-
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
122+
DataStream stream{};
123123
stream << orig;
124124
stream >> *this;
125125
}
126126
explicit TestHeaderAndShortIDs(const CBlock& block) :
127127
TestHeaderAndShortIDs(CBlockHeaderAndShortTxIDs{block}) {}
128128

129129
uint64_t GetShortID(const uint256& txhash) const {
130-
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
130+
DataStream stream{};
131131
stream << *this;
132132
CBlockHeaderAndShortTxIDs base;
133133
stream >> base;
@@ -158,7 +158,7 @@ BOOST_AUTO_TEST_CASE(NonCoinbasePreforwardRTTest)
158158
shortIDs.shorttxids[0] = shortIDs.GetShortID(block.vtx[0]->GetHash());
159159
shortIDs.shorttxids[1] = shortIDs.GetShortID(block.vtx[2]->GetHash());
160160

161-
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
161+
DataStream stream{};
162162
stream << shortIDs;
163163

164164
CBlockHeaderAndShortTxIDs shortIDs2;
@@ -228,7 +228,7 @@ BOOST_AUTO_TEST_CASE(SufficientPreforwardRTTest)
228228
shortIDs.shorttxids.resize(1);
229229
shortIDs.shorttxids[0] = shortIDs.GetShortID(block.vtx[1]->GetHash());
230230

231-
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
231+
DataStream stream{};
232232
stream << shortIDs;
233233

234234
CBlockHeaderAndShortTxIDs shortIDs2;
@@ -283,7 +283,7 @@ BOOST_AUTO_TEST_CASE(EmptyBlockRoundTripTest)
283283
{
284284
CBlockHeaderAndShortTxIDs shortIDs{block};
285285

286-
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
286+
DataStream stream{};
287287
stream << shortIDs;
288288

289289
CBlockHeaderAndShortTxIDs shortIDs2;

src/test/net_tests.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,7 @@ class V2TransportTester
11261126
void SendV1Version(const MessageStartChars& magic)
11271127
{
11281128
CMessageHeader hdr(magic, "version", 126 + InsecureRandRange(11));
1129-
CDataStream ser(SER_NETWORK, CLIENT_VERSION);
1129+
DataStream ser{};
11301130
ser << hdr;
11311131
m_to_send.insert(m_to_send.end(), UCharCast(ser.data()), UCharCast(ser.data() + ser.size()));
11321132
}

src/wallet/db.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class DatabaseBatch
6767
ssKey.reserve(1000);
6868
ssKey << key;
6969

70-
CDataStream ssValue(SER_DISK, CLIENT_VERSION);
70+
DataStream ssValue{};
7171
if (!ReadKey(std::move(ssKey), ssValue)) return false;
7272
try {
7373
ssValue >> value;
@@ -84,7 +84,7 @@ class DatabaseBatch
8484
ssKey.reserve(1000);
8585
ssKey << key;
8686

87-
CDataStream ssValue(SER_DISK, CLIENT_VERSION);
87+
DataStream ssValue{};
8888
ssValue.reserve(10000);
8989
ssValue << value;
9090

src/wallet/rpc/spend.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ static UniValue FinishTransaction(const std::shared_ptr<CWallet> pwallet, const
100100
bool add_to_wallet{options.exists("add_to_wallet") ? options["add_to_wallet"].get_bool() : true};
101101
if (psbt_opt_in || !complete || !add_to_wallet) {
102102
// Serialize the PSBT
103-
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
103+
DataStream ssTx{};
104104
ssTx << psbtx;
105105
result.pushKV("psbt", EncodeBase64(ssTx.str()));
106106
}
@@ -1165,7 +1165,7 @@ static RPCHelpMan bumpfee_helper(std::string method_name)
11651165
const TransactionError err = pwallet->FillPSBT(psbtx, complete, SIGHASH_DEFAULT, /*sign=*/false, /*bip32derivs=*/true);
11661166
CHECK_NONFATAL(err == TransactionError::OK);
11671167
CHECK_NONFATAL(!complete);
1168-
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
1168+
DataStream ssTx{};
11691169
ssTx << psbtx;
11701170
result.pushKV("psbt", EncodeBase64(ssTx.str()));
11711171
}
@@ -1610,7 +1610,7 @@ RPCHelpMan walletprocesspsbt()
16101610
}
16111611

16121612
UniValue result(UniValue::VOBJ);
1613-
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
1613+
DataStream ssTx{};
16141614
ssTx << psbtx;
16151615
result.pushKV("psbt", EncodeBase64(ssTx.str()));
16161616
result.pushKV("complete", complete);
@@ -1737,7 +1737,7 @@ RPCHelpMan walletcreatefundedpsbt()
17371737
}
17381738

17391739
// Serialize the PSBT
1740-
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
1740+
DataStream ssTx{};
17411741
ssTx << psbtx;
17421742

17431743
UniValue result(UniValue::VOBJ);

src/wallet/test/psbt_wallet_tests.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ BOOST_AUTO_TEST_CASE(psbt_updater_test)
5757
BOOST_REQUIRE_EQUAL(TransactionError::OK, m_wallet.FillPSBT(psbtx, complete, SIGHASH_ALL, false, true));
5858

5959
// Get the final tx
60-
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
60+
DataStream ssTx{};
6161
ssTx << psbtx;
6262
std::string final_hex = HexStr(ssTx);
6363
BOOST_CHECK_EQUAL(final_hex, "70736274ff01009a020000000258e87a21b56daf0c23be8e7070456c336f7cbaa5c8757924f545887bb2abdd750000000000ffffffff838d0427d0ec650a68aa46bb0b098aea4422c071b2ca78352a077959d07cea1d0100000000ffffffff0270aaf00800000000160014d85c2b71d0060b09c9886aeb815e50991dda124d00e1f5050000000016001400aea9a2e5f0f876a588df5546e8742d1d87008f00000000000100bb0200000001aad73931018bd25f84ae400b68848be09db706eac2ac18298babee71ab656f8b0000000048473044022058f6fc7c6a33e1b31548d481c826c015bd30135aad42cd67790dab66d2ad243b02204a1ced2604c6735b6393e5b41691dd78b00f0c5942fb9f751856faa938157dba01feffffff0280f0fa020000000017a9140fb9463421696b82c833af241c78c17ddbde493487d0f20a270100000017a91429ca74f8a08f81999428185c97b5d852e4063f6187650000000104475221029583bf39ae0a609747ad199addd634fa6108559d6c5cd39b4c2183f1ab96e07f2102dab61ff49a14db6a7d02b0cd1fbb78fc4b18312b5b4e54dae4dba2fbfef536d752ae2206029583bf39ae0a609747ad199addd634fa6108559d6c5cd39b4c2183f1ab96e07f10d90c6a4f000000800000008000000080220602dab61ff49a14db6a7d02b0cd1fbb78fc4b18312b5b4e54dae4dba2fbfef536d710d90c6a4f0000008000000080010000800001008a020000000158e87a21b56daf0c23be8e7070456c336f7cbaa5c8757924f545887bb2abdd7501000000171600145f275f436b09a8cc9a2eb2a2f528485c68a56323feffffff02d8231f1b0100000017a914aed962d6654f9a2b36608eb9d64d2b260db4f1118700c2eb0b0000000017a914b7f5faf40e3d40a5a459b1db3535f2b72fa921e8876500000001012000c2eb0b0000000017a914b7f5faf40e3d40a5a459b1db3535f2b72fa921e88701042200208c2353173743b595dfb4a07b72ba8e42e3797da74e87fe7d9d7497e3b2028903010547522103089dc10c7ac6db54f91329af617333db388cead0c231f723379d1b99030b02dc21023add904f3d6dcf59ddb906b0dee23529b7ffb9ed50e5e86151926860221f0e7352ae2206023add904f3d6dcf59ddb906b0dee23529b7ffb9ed50e5e86151926860221f0e7310d90c6a4f000000800000008003000080220603089dc10c7ac6db54f91329af617333db388cead0c231f723379d1b99030b02dc10d90c6a4f00000080000000800200008000220203a9a4c37f5996d3aa25dbac6b570af0650394492942460b354753ed9eeca5877110d90c6a4f000000800000008004000080002202027f6399757d2eff55a136ad02c684b1838b6556e5f1b6b34282a94b6b5005109610d90c6a4f00000080000000800500008000");

src/wallet/test/walletdb_tests.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ BOOST_AUTO_TEST_CASE(walletdb_readkeyvalue)
2424
* silently fail. The test here makes sure the type of exception thrown from CDataStream::read()
2525
* matches the type we expect, otherwise we need to update the "key"/"wkey" exception type caught.
2626
*/
27-
CDataStream ssValue(SER_DISK, CLIENT_VERSION);
27+
DataStream ssValue{};
2828
uint256 dummy;
2929
BOOST_CHECK_THROW(ssValue >> dummy, std::ios_base::failure);
3030
}

0 commit comments

Comments
 (0)