cbitcoin
|
00001 // 00002 // CBTransaction.h 00003 // cbitcoin 00004 // 00005 // Created by Matthew Mitchell on 02/05/2012. 00006 // Copyright (c) 2012 Matthew Mitchell 00007 // 00008 // This file is part of cbitcoin. 00009 // 00010 // cbitcoin is free software: you can redistribute it and/or modify 00011 // it under the terms of the GNU General Public License as published by 00012 // the Free Software Foundation, either version 3 of the License, or 00013 // (at your option) any later version. 00014 // 00015 // cbitcoin is distributed in the hope that it will be useful, 00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 // GNU General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU General Public License 00021 // along with cbitcoin. If not, see <http://www.gnu.org/licenses/>. 00022 00028 #ifndef CBTRANSACTIONH 00029 #define CBTRANSACTIONH 00030 00031 // Includes 00032 00033 #include "CBMessage.h" 00034 #include "CBTransactionInput.h" 00035 #include "CBTransactionOutput.h" 00036 00040 typedef struct{ 00041 CBMessage base; 00042 uint32_t version; 00043 uint32_t inputNum; 00044 CBTransactionInput ** inputs; 00045 uint32_t outputNum; 00046 CBTransactionOutput ** outputs; 00047 uint32_t lockTime; 00048 } CBTransaction; 00049 00054 CBTransaction * CBNewTransaction(uint32_t lockTime, uint32_t version, void (*onErrorReceived)(CBError error,char *,...)); 00059 CBTransaction * CBNewTransactionFromData(CBByteArray * bytes, void (*onErrorReceived)(CBError error,char *,...)); 00060 00066 CBTransaction * CBGetTransaction(void * self); 00067 00073 bool CBInitTransaction(CBTransaction * self, uint32_t lockTime, uint32_t version, void (*onErrorReceived)(CBError error,char *,...)); 00080 bool CBInitTransactionFromData(CBTransaction * self, CBByteArray * data,void (*onErrorReceived)(CBError error,char *,...)); 00081 00086 void CBFreeTransaction(void * self); 00087 00088 // Functions 00089 00096 bool CBTransactionAddInput(CBTransaction * self, CBTransactionInput * input); 00103 bool CBTransactionAddOutput(CBTransaction * self, CBTransactionOutput * output); 00109 uint32_t CBTransactionCalculateLength(CBTransaction * self); 00115 uint32_t CBTransactionDeserialise(CBTransaction * self); 00125 CBGetHashReturn CBTransactionGetInputHashForSignature(void * vself, CBByteArray * prevOutSubScript, uint32_t input, CBSignType signType, uint8_t * hash); 00131 bool CBTransactionIsCoinBase(CBTransaction * self); 00137 uint32_t CBTransactionSerialise(CBTransaction * self); 00144 bool CBTransactionTakeInput(CBTransaction * self, CBTransactionInput * input); 00151 bool CBTransactionTakeOutput(CBTransaction * self, CBTransactionOutput * output); 00152 00153 #endif