pandanite-crypto / pandanite

Simple, elegant, fast, Layer-1 blockchain based cryptocurrency written in 6k lines of C++
MIT License
30 stars 40 forks source link

BMB001 : Extend transaction data type to support 32 byte program ID and 128 bytes of data storage #97

Closed mr-pandabear closed 2 years ago

mr-pandabear commented 2 years ago

Several changes in this proposal to support the Rhizome Virtual Blockchain:

  1. The timestamp will now act as a FLAG -- if set to -1 the transaction will be discarded from the main mempool and instead forwarded only to nodes running a particular virtual blockchain.
  2. The TransactionInfo struct will now contain an additional 32 byte program ID (identifying the program the transaction data should be sent to) as well as a 128 byte data field which my be utilized to store arbitrary data. The full transaction data will be forwarded on to the virtual blockchain for processing.
  3. Transaction hashing and data storage will remain the same -- only network transmission of transactions will change. LevelDB will not store the additional programID and data fields.

The newly proposed structure is as follows:

struct TransactionInfo {
    char signature[64];
    char signingKey[32];
    uint64_t timestamp;
    PublicWalletAddress to;
    PublicWalletAddress from;
    TransactionAmount amount;
    TransactionAmount fee;
    bool isTransactionFee;
    char targetProgram[32];
    char data[128];
};

Modifications will need to be made to the serialization and deserialization functions below:

TransactionInfo transactionInfoFromBuffer(const char* buffer);
void transactionInfoToBuffer(TransactionInfo& t, char* buffer);

Furthermore, BlockStore will need to be updated to no longer use these functions when serializing/deserializing transactions to discard the targetProgram and data fields when writing to LevelDB