Changeset View
Changeset View
Standalone View
Standalone View
src/primitives/transaction.cpp
// Copyright (c) 2009-2010 Satoshi Nakamoto | // Copyright (c) 2009-2010 Satoshi Nakamoto | ||||
// Copyright (c) 2009-2016 The Bitcoin Core developers | // Copyright (c) 2009-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include "primitives/transaction.h" | #include "primitives/transaction.h" | ||||
#include "hash.h" | #include "hash.h" | ||||
#include "tinyformat.h" | #include "tinyformat.h" | ||||
#include "utilstrencodings.h" | #include "utilstrencodings.h" | ||||
std::string COutPoint::ToString() const { | std::string COutPoint::ToString() const { | ||||
return strprintf("COutPoint(%s, %u)", hash.ToString().substr(0, 10), n); | return strprintf("COutPoint(%s, %u)", hash.ToString().substr(0, 10), n); | ||||
} | } | ||||
CTxIn::CTxIn(COutPoint prevoutIn, CScript scriptSigIn, uint32_t nSequenceIn) { | |||||
prevout = prevoutIn; | |||||
scriptSig = scriptSigIn; | |||||
nSequence = nSequenceIn; | |||||
} | |||||
CTxIn::CTxIn(uint256 hashPrevTx, uint32_t nOut, CScript scriptSigIn, | |||||
uint32_t nSequenceIn) { | |||||
prevout = COutPoint(hashPrevTx, nOut); | |||||
scriptSig = scriptSigIn; | |||||
nSequence = nSequenceIn; | |||||
} | |||||
std::string CTxIn::ToString() const { | std::string CTxIn::ToString() const { | ||||
std::string str; | std::string str; | ||||
str += "CTxIn("; | str += "CTxIn("; | ||||
str += prevout.ToString(); | str += prevout.ToString(); | ||||
if (prevout.IsNull()) { | if (prevout.IsNull()) { | ||||
str += strprintf(", coinbase %s", HexStr(scriptSig)); | str += strprintf(", coinbase %s", HexStr(scriptSig)); | ||||
} else { | } else { | ||||
str += strprintf(", scriptSig=%s", HexStr(scriptSig).substr(0, 24)); | str += strprintf(", scriptSig=%s", HexStr(scriptSig).substr(0, 24)); | ||||
} | } | ||||
if (nSequence != SEQUENCE_FINAL) { | if (nSequence != SEQUENCE_FINAL) { | ||||
str += strprintf(", nSequence=%u", nSequence); | str += strprintf(", nSequence=%u", nSequence); | ||||
} | } | ||||
str += ")"; | str += ")"; | ||||
return str; | return str; | ||||
} | } | ||||
CTxOut::CTxOut(const Amount &nValueIn, CScript scriptPubKeyIn) { | |||||
nValue = nValueIn; | |||||
scriptPubKey = scriptPubKeyIn; | |||||
} | |||||
std::string CTxOut::ToString() const { | std::string CTxOut::ToString() const { | ||||
return strprintf("CTxOut(nValue=%d.%08d, scriptPubKey=%s)", | return strprintf("CTxOut(nValue=%d.%08d, scriptPubKey=%s)", | ||||
nValue.GetSatoshis() / COIN.GetSatoshis(), | nValue.GetSatoshis() / COIN.GetSatoshis(), | ||||
nValue.GetSatoshis() % COIN.GetSatoshis(), | nValue.GetSatoshis() % COIN.GetSatoshis(), | ||||
HexStr(scriptPubKey).substr(0, 30)); | HexStr(scriptPubKey).substr(0, 30)); | ||||
} | } | ||||
CMutableTransaction::CMutableTransaction() | CMutableTransaction::CMutableTransaction() | ||||
▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | str += strprintf("CTransaction(txid=%s, ver=%d, vin.size=%u, vout.size=%u, " | ||||
GetId().ToString().substr(0, 10), nVersion, vin.size(), | GetId().ToString().substr(0, 10), nVersion, vin.size(), | ||||
vout.size(), nLockTime); | vout.size(), nLockTime); | ||||
for (unsigned int i = 0; i < vin.size(); i++) | for (unsigned int i = 0; i < vin.size(); i++) | ||||
str += " " + vin[i].ToString() + "\n"; | str += " " + vin[i].ToString() + "\n"; | ||||
for (unsigned int i = 0; i < vout.size(); i++) | for (unsigned int i = 0; i < vout.size(); i++) | ||||
str += " " + vout[i].ToString() + "\n"; | str += " " + vout[i].ToString() + "\n"; | ||||
return str; | return str; | ||||
} | } | ||||
No newline at end of file | No newline at end of file |