twisterp2pblockchainnetworkbittorrentipv6microbloggingsocial-networkdhtdecentralizedtwister-coretwisterarmyp2p-networktwister-servertwister-ipv6
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
110 lines
2.4 KiB
110 lines
2.4 KiB
14 years ago
|
#ifndef TRANSACTIONRECORD_H
|
||
|
#define TRANSACTIONRECORD_H
|
||
|
|
||
|
#include "main.h"
|
||
|
|
||
|
#include <QList>
|
||
|
|
||
|
class TransactionStatus
|
||
|
{
|
||
|
public:
|
||
|
TransactionStatus():
|
||
|
confirmed(false), sortKey(""), maturity(Mature),
|
||
14 years ago
|
matures_in(0), status(Offline), depth(0), open_for(0), cur_num_blocks(-1)
|
||
14 years ago
|
{ }
|
||
|
|
||
|
enum Maturity
|
||
|
{
|
||
|
Immature,
|
||
|
Mature,
|
||
|
MaturesWarning, /* Will likely not mature because no nodes have confirmed */
|
||
|
NotAccepted
|
||
|
};
|
||
|
|
||
|
enum Status {
|
||
|
OpenUntilDate,
|
||
|
OpenUntilBlock,
|
||
|
Offline,
|
||
|
Unconfirmed,
|
||
|
HaveConfirmations
|
||
|
};
|
||
|
|
||
|
bool confirmed;
|
||
|
std::string sortKey;
|
||
|
|
||
|
/* For "Generated" transactions */
|
||
|
Maturity maturity;
|
||
|
int matures_in;
|
||
|
|
||
|
/* Reported status */
|
||
|
Status status;
|
||
|
int64 depth;
|
||
|
int64 open_for; /* Timestamp if status==OpenUntilDate, otherwise number of blocks */
|
||
14 years ago
|
|
||
|
/* Current number of blocks (to know whether cached status is still valid. */
|
||
|
int cur_num_blocks;
|
||
14 years ago
|
};
|
||
|
|
||
|
class TransactionRecord
|
||
|
{
|
||
|
public:
|
||
|
enum Type
|
||
|
{
|
||
|
Other,
|
||
|
Generated,
|
||
|
SendToAddress,
|
||
|
SendToIP,
|
||
14 years ago
|
RecvWithAddress,
|
||
14 years ago
|
RecvFromIP,
|
||
|
SendToSelf
|
||
|
};
|
||
|
|
||
|
TransactionRecord():
|
||
14 years ago
|
hash(), time(0), type(Other), address(""), debit(0), credit(0), idx(0)
|
||
14 years ago
|
{
|
||
|
}
|
||
|
|
||
14 years ago
|
TransactionRecord(uint256 hash, int64 time):
|
||
14 years ago
|
hash(hash), time(time), type(Other), address(""), debit(0),
|
||
14 years ago
|
credit(0), idx(0)
|
||
14 years ago
|
{
|
||
|
}
|
||
|
|
||
14 years ago
|
TransactionRecord(uint256 hash, int64 time,
|
||
14 years ago
|
Type type, const std::string &address,
|
||
|
int64 debit, int64 credit):
|
||
|
hash(hash), time(time), type(type), address(address), debit(debit), credit(credit),
|
||
14 years ago
|
idx(0)
|
||
14 years ago
|
{
|
||
|
}
|
||
|
|
||
14 years ago
|
/* Decompose CWallet transaction to model transaction records.
|
||
|
*/
|
||
14 years ago
|
static bool showTransaction(const CWalletTx &wtx);
|
||
|
static QList<TransactionRecord> decomposeTransaction(const CWalletTx &wtx);
|
||
|
|
||
|
/* Fixed */
|
||
|
uint256 hash;
|
||
|
int64 time;
|
||
|
Type type;
|
||
|
std::string address;
|
||
|
int64 debit;
|
||
|
int64 credit;
|
||
|
|
||
14 years ago
|
/* Subtransaction index, for sort key */
|
||
|
int idx;
|
||
|
|
||
14 years ago
|
/* Status: can change with block chain update */
|
||
|
TransactionStatus status;
|
||
14 years ago
|
|
||
|
/* Update status from wallet tx.
|
||
|
*/
|
||
|
void updateStatus(const CWalletTx &wtx);
|
||
|
|
||
|
/* Is a status update needed?
|
||
|
*/
|
||
|
bool statusUpdateNeeded();
|
||
14 years ago
|
};
|
||
|
|
||
|
#endif // TRANSACTIONRECORD_H
|