@@ -37,8 +37,7 @@ void ScriptPubKeyToJSON(const CScript& scriptPubKey, Object& out, bool fIncludeH
37
37
if (fIncludeHex )
38
38
out.push_back (Pair (" hex" , HexStr (scriptPubKey.begin (), scriptPubKey.end ())));
39
39
40
- if (!ExtractDestinations (scriptPubKey, type, addresses, nRequired))
41
- {
40
+ if (!ExtractDestinations (scriptPubKey, type, addresses, nRequired)) {
42
41
out.push_back (Pair (" type" , GetTxnOutputType (type)));
43
42
return ;
44
43
}
@@ -58,13 +57,11 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry)
58
57
entry.push_back (Pair (" version" , tx.nVersion ));
59
58
entry.push_back (Pair (" locktime" , (int64_t )tx.nLockTime ));
60
59
Array vin;
61
- BOOST_FOREACH (const CTxIn& txin, tx.vin )
62
- {
60
+ BOOST_FOREACH (const CTxIn& txin, tx.vin ) {
63
61
Object in;
64
62
if (tx.IsCoinBase ())
65
63
in.push_back (Pair (" coinbase" , HexStr (txin.scriptSig .begin (), txin.scriptSig .end ())));
66
- else
67
- {
64
+ else {
68
65
in.push_back (Pair (" txid" , txin.prevout .hash .GetHex ()));
69
66
in.push_back (Pair (" vout" , (int64_t )txin.prevout .n ));
70
67
Object o;
@@ -77,8 +74,7 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry)
77
74
}
78
75
entry.push_back (Pair (" vin" , vin));
79
76
Array vout;
80
- for (unsigned int i = 0 ; i < tx.vout .size (); i++)
81
- {
77
+ for (unsigned int i = 0 ; i < tx.vout .size (); i++) {
82
78
const CTxOut& txout = tx.vout [i];
83
79
Object out;
84
80
out.push_back (Pair (" value" , ValueFromAmount (txout.nValue )));
@@ -90,15 +86,12 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry)
90
86
}
91
87
entry.push_back (Pair (" vout" , vout));
92
88
93
- if (hashBlock != 0 )
94
- {
89
+ if (hashBlock != 0 ) {
95
90
entry.push_back (Pair (" blockhash" , hashBlock.GetHex ()));
96
91
map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find (hashBlock);
97
- if (mi != mapBlockIndex.end () && (*mi).second )
98
- {
92
+ if (mi != mapBlockIndex.end () && (*mi).second ) {
99
93
CBlockIndex* pindex = (*mi).second ;
100
- if (chainActive.Contains (pindex))
101
- {
94
+ if (chainActive.Contains (pindex)) {
102
95
entry.push_back (Pair (" confirmations" , 1 + chainActive.Height () - pindex->nHeight ));
103
96
entry.push_back (Pair (" time" , pindex->GetBlockTime ()));
104
97
entry.push_back (Pair (" blocktime" , pindex->GetBlockTime ()));
@@ -244,11 +237,9 @@ Value listunspent(const Array& params, bool fHelp)
244
237
nMaxDepth = params[1 ].get_int ();
245
238
246
239
set<CBitcoinAddress> setAddress;
247
- if (params.size () > 2 )
248
- {
240
+ if (params.size () > 2 ) {
249
241
Array inputs = params[2 ].get_array ();
250
- BOOST_FOREACH (Value& input, inputs)
251
- {
242
+ BOOST_FOREACH (Value& input, inputs) {
252
243
CBitcoinAddress address (input.get_str ());
253
244
if (!address.IsValid ())
254
245
throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, string (" Invalid Bitcoin address: " )+input.get_str ());
@@ -262,13 +253,11 @@ Value listunspent(const Array& params, bool fHelp)
262
253
vector<COutput> vecOutputs;
263
254
assert (pwalletMain != NULL );
264
255
pwalletMain->AvailableCoins (vecOutputs, false );
265
- BOOST_FOREACH (const COutput& out, vecOutputs)
266
- {
256
+ BOOST_FOREACH (const COutput& out, vecOutputs) {
267
257
if (out.nDepth < nMinDepth || out.nDepth > nMaxDepth)
268
258
continue ;
269
259
270
- if (setAddress.size ())
271
- {
260
+ if (setAddress.size ()) {
272
261
CTxDestination address;
273
262
if (!ExtractDestination (out.tx ->vout [out.i ].scriptPubKey , address))
274
263
continue ;
@@ -283,18 +272,15 @@ Value listunspent(const Array& params, bool fHelp)
283
272
entry.push_back (Pair (" txid" , out.tx ->GetHash ().GetHex ()));
284
273
entry.push_back (Pair (" vout" , out.i ));
285
274
CTxDestination address;
286
- if (ExtractDestination (out.tx ->vout [out.i ].scriptPubKey , address))
287
- {
275
+ if (ExtractDestination (out.tx ->vout [out.i ].scriptPubKey , address)) {
288
276
entry.push_back (Pair (" address" , CBitcoinAddress (address).ToString ()));
289
277
if (pwalletMain->mapAddressBook .count (address))
290
278
entry.push_back (Pair (" account" , pwalletMain->mapAddressBook [address].name ));
291
279
}
292
280
entry.push_back (Pair (" scriptPubKey" , HexStr (pk.begin (), pk.end ())));
293
- if (pk.IsPayToScriptHash ())
294
- {
281
+ if (pk.IsPayToScriptHash ()) {
295
282
CTxDestination address;
296
- if (ExtractDestination (pk, address))
297
- {
283
+ if (ExtractDestination (pk, address)) {
298
284
const CScriptID& hash = boost::get<const CScriptID&>(address);
299
285
CScript redeemScript;
300
286
if (pwalletMain->GetCScript (hash, redeemScript))
@@ -351,8 +337,7 @@ Value createrawtransaction(const Array& params, bool fHelp)
351
337
352
338
CMutableTransaction rawTx;
353
339
354
- BOOST_FOREACH (const Value& input, inputs)
355
- {
340
+ BOOST_FOREACH (const Value& input, inputs) {
356
341
const Object& o = input.get_obj ();
357
342
358
343
uint256 txid = ParseHashO (o, " txid" );
@@ -369,8 +354,7 @@ Value createrawtransaction(const Array& params, bool fHelp)
369
354
}
370
355
371
356
set<CBitcoinAddress> setAddress;
372
- BOOST_FOREACH (const Pair& s, sendTo)
373
- {
357
+ BOOST_FOREACH (const Pair& s, sendTo) {
374
358
CBitcoinAddress address (s.name_ );
375
359
if (!address.IsValid ())
376
360
throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, string (" Invalid Bitcoin address: " )+s.name_ );
@@ -550,8 +534,7 @@ Value signrawtransaction(const Array& params, bool fHelp)
550
534
vector<unsigned char > txData (ParseHexV (params[0 ], " argument 1" ));
551
535
CDataStream ssData (txData, SER_NETWORK, PROTOCOL_VERSION);
552
536
vector<CMutableTransaction> txVariants;
553
- while (!ssData.empty ())
554
- {
537
+ while (!ssData.empty ()) {
555
538
try {
556
539
CMutableTransaction tx;
557
540
ssData >> tx;
@@ -590,12 +573,10 @@ Value signrawtransaction(const Array& params, bool fHelp)
590
573
591
574
bool fGivenKeys = false ;
592
575
CBasicKeyStore tempKeystore;
593
- if (params.size () > 2 && params[2 ].type () != null_type)
594
- {
576
+ if (params.size () > 2 && params[2 ].type () != null_type) {
595
577
fGivenKeys = true ;
596
578
Array keys = params[2 ].get_array ();
597
- BOOST_FOREACH (Value k, keys)
598
- {
579
+ BOOST_FOREACH (Value k, keys) {
599
580
CBitcoinSecret vchSecret;
600
581
bool fGood = vchSecret.SetString (k.get_str ());
601
582
if (!fGood )
@@ -610,11 +591,9 @@ Value signrawtransaction(const Array& params, bool fHelp)
610
591
#endif
611
592
612
593
// Add previous txouts given in the RPC call:
613
- if (params.size () > 1 && params[1 ].type () != null_type)
614
- {
594
+ if (params.size () > 1 && params[1 ].type () != null_type) {
615
595
Array prevTxs = params[1 ].get_array ();
616
- BOOST_FOREACH (Value& p, prevTxs)
617
- {
596
+ BOOST_FOREACH (Value& p, prevTxs) {
618
597
if (p.type () != obj_type)
619
598
throw JSONRPCError (RPC_DESERIALIZATION_ERROR, " expected object with {\" txid'\" ,\" vout\" ,\" scriptPubKey\" }" );
620
599
@@ -649,12 +628,10 @@ Value signrawtransaction(const Array& params, bool fHelp)
649
628
650
629
// if redeemScript given and not using the local wallet (private keys
651
630
// given), add redeemScript to the tempKeystore so it can be signed:
652
- if (fGivenKeys && scriptPubKey.IsPayToScriptHash ())
653
- {
631
+ if (fGivenKeys && scriptPubKey.IsPayToScriptHash ()) {
654
632
RPCTypeCheck (prevOut, map_list_of (" txid" , str_type)(" vout" , int_type)(" scriptPubKey" , str_type)(" redeemScript" ,str_type));
655
633
Value v = find_value (prevOut, " redeemScript" );
656
- if (!(v == Value::null))
657
- {
634
+ if (!(v == Value::null)) {
658
635
vector<unsigned char > rsData (ParseHexV (v, " redeemScript" ));
659
636
CScript redeemScript (rsData.begin (), rsData.end ());
660
637
tempKeystore.AddCScript (redeemScript);
@@ -670,8 +647,7 @@ Value signrawtransaction(const Array& params, bool fHelp)
670
647
#endif
671
648
672
649
int nHashType = SIGHASH_ALL;
673
- if (params.size () > 3 && params[3 ].type () != null_type)
674
- {
650
+ if (params.size () > 3 && params[3 ].type () != null_type) {
675
651
static map<string, int > mapSigHashValues =
676
652
boost::assign::map_list_of
677
653
(string (" ALL" ), int (SIGHASH_ALL))
@@ -691,12 +667,10 @@ Value signrawtransaction(const Array& params, bool fHelp)
691
667
bool fHashSingle = ((nHashType & ~SIGHASH_ANYONECANPAY) == SIGHASH_SINGLE);
692
668
693
669
// Sign what we can:
694
- for (unsigned int i = 0 ; i < mergedTx.vin .size (); i++)
695
- {
670
+ for (unsigned int i = 0 ; i < mergedTx.vin .size (); i++) {
696
671
CTxIn& txin = mergedTx.vin [i];
697
672
CCoins coins;
698
- if (!view.GetCoins (txin.prevout .hash , coins) || !coins.IsAvailable (txin.prevout .n ))
699
- {
673
+ if (!view.GetCoins (txin.prevout .hash , coins) || !coins.IsAvailable (txin.prevout .n )) {
700
674
fComplete = false ;
701
675
continue ;
702
676
}
@@ -708,8 +682,7 @@ Value signrawtransaction(const Array& params, bool fHelp)
708
682
SignSignature (keystore, prevPubKey, mergedTx, i, nHashType);
709
683
710
684
// ... and merge in other signatures:
711
- BOOST_FOREACH (const CMutableTransaction& txv, txVariants)
712
- {
685
+ BOOST_FOREACH (const CMutableTransaction& txv, txVariants) {
713
686
txin.scriptSig = CombineSignatures (prevPubKey, mergedTx, i, txin.scriptSig , txv.vin [i].scriptSig );
714
687
}
715
688
if (!VerifyScript (txin.scriptSig , prevPubKey, mergedTx, i, STANDARD_SCRIPT_VERIFY_FLAGS, 0 ))
0 commit comments