This commit is contained in:
JoelKatz
2012-03-18 11:13:20 -07:00
parent 99493c662a
commit 50cb87087c
3 changed files with 69 additions and 6 deletions

View File

@@ -5,13 +5,17 @@
#include "SerializedTypes.h"
enum SOE_Type
{
SOE_NEVER=-1, SOE_REQUIRED=0, SOE_FLAGS, SOE_IFFLAG=1, SOE_IFNFLAG=2
};
struct SOElement
{ // An element in the description of a serialized object
const char *e_name;
int e_flag;
SerializedTypeID e_id;
SOElement(const char *n, int f, SerializedTypeID i) : e_name(n), e_flag(f), e_id(i) { ; }
SOE_Type e_type;
int e_flags;
};
struct SOType

View File

@@ -9,9 +9,9 @@
enum SerializedTypeID
{
STI_NOTPRESENT=0, STI_OBJECT=1,
STI_UINT8=2, STI_UINT16=3, STI_UINT32=4, STI_UINT64=5,
STI_HASH160=6, STI_HASH256=7, STI_VL=8, STI_TL=8
STI_DONE=-1, STI_NOTPRESENT=0,
STI_OBJECT=1, STI_UINT8=2, STI_UINT16=3, STI_UINT32=4, STI_UINT64=5,
STI_HASH160=6, STI_HASH256=7, STI_VL=8, STI_TL=8,
};
class SerializedType

59
src/TransactionFormats.h Normal file
View File

@@ -0,0 +1,59 @@
#ifndef __TRANSACTIONFORMATS__
#define __TRANSACTIONFORMATS__
#include "SerializedObject.h"
#define STI_ACCOUNT STI_HASH160
struct TransactionFormat
{
const char *t_name;
int t_id;
SOElement elements[16];
};
TransactionFormat InnerTxnFormats[]=
{
{ "MakePayment", 0, {
{ "Flags", STI_UINT16, SOE_FLAGS, 0 },
{ "Sequence", STI_UINT32, SOE_REQUIRED, 0 },
{ "Destination", STI_ACCOUNT, SOE_REQUIRED, 0 },
{ "Amount", STI_UINT64, SOE_REQUIRED, 0 },
{ "Currency", STI_HASH160, SOE_IFFLAG, 1 },
{ "SourceTag", STI_UINT32, SOE_IFFLAG, 2 },
{ "TargetLedger", STI_UINT32, SOE_IFFLAG, 4 },
{ "InvoiceID", STI_HASH256, SOE_IFFLAG, 8 },
{ "Extensions", STI_TL, SOE_IFFLAG, 32768 },
{ NULL, STI_DONE, SOE_NEVER, -1 } }
},
{ "Invoice", 1, {
{ "Flags", STI_UINT16, SOE_FLAGS, 0 },
{ "Sequence", STI_UINT32, SOE_REQUIRED, 0 },
{ "Target", STI_ACCOUNT, SOE_REQUIRED, 0 },
{ "Amount", STI_UINT64, SOE_REQUIRED, 0 },
{ "Currency", STI_HASH160, SOE_IFFLAG, 1 },
{ "SourceTag", STI_UINT32, SOE_IFFLAG, 2 },
{ "Destination", STI_ACCOUNT, SOE_IFFLAG, 4 },
{ "TargetLedger", STI_UINT32, SOE_IFFLAG, 8 },
{ "Identifier", STI_VL, SOE_IFFLAG, 16 },
{ "Extensions", STI_TL, SOE_IFFLAG, 32768 },
{ NULL, STI_DONE, SOE_NEVER, -1 } }
},
{ "Offer", 2, {
{ "Flags", STI_UINT16, SOE_FLAGS, 0 },
{ "Sequence", STI_UINT32, SOE_REQUIRED, 0 },
{ "AmountIn", STI_UINT64, SOE_REQUIRED, 0 },
{ "CurrencyIn", STI_HASH160, SOE_IFFLAG, 2 },
{ "AmountOut", STI_UINT64, SOE_REQUIRED, 0 },
{ "CurrencyOut", STI_HASH160, SOE_IFFLAG, 4 },
{ "SourceTag", STI_UINT32, SOE_IFFLAG, 8 },
{ "Destination", STI_ACCOUNT, SOE_IFFLAG, 16 },
{ "TargetLedger", STI_UINT32, SOE_IFFLAG, 32 },
{ "ExpireLedger", STI_UINT32, SOE_IFFLAG, 64 },
{ "Identifier", STI_VL, SOE_IFFLAG, 128 },
{ "Extensions", STI_TL, SOE_IFFLAG, 32768 },
{ NULL, STI_DONE, SOE_NEVER, -1 } }
}
};
#endif