void ABC_TxDetailsFree(tABC_TxDetails *pDetails) { if (pDetails) { ABC_FREE_STR(pDetails->szName); ABC_FREE_STR(pDetails->szCategory); ABC_FREE_STR(pDetails->szNotes); ABC_CLEAR_FREE(pDetails, sizeof(tABC_TxDetails)); } }
/** * Frees a CarePackage object and all its members. */ void ABC_CarePackageFree(tABC_CarePackage *pSelf) { if (pSelf) { ABC_CryptoFreeSNRP(&pSelf->pSNRP1); ABC_CryptoFreeSNRP(&pSelf->pSNRP2); ABC_CryptoFreeSNRP(&pSelf->pSNRP3); ABC_CryptoFreeSNRP(&pSelf->pSNRP4); if (pSelf->ERQ) json_decref(pSelf->ERQ); ABC_CLEAR_FREE(pSelf, sizeof(tABC_CarePackage)); } }
/** * Frees a LoginPackage object and all its members. */ void ABC_LoginPackageFree(tABC_LoginPackage *pSelf) { if (pSelf) { if (pSelf->EMK_LP2) json_decref(pSelf->EMK_LP2); if (pSelf->EMK_LRA3) json_decref(pSelf->EMK_LRA3); if (pSelf->ESyncKey) json_decref(pSelf->ESyncKey); if (pSelf->ELP1) json_decref(pSelf->ELP1); if (pSelf->ELRA1) json_decref(pSelf->ELRA1); ABC_CLEAR_FREE(pSelf, sizeof(tABC_LoginPackage)); } }
/** * Frees the general info struct. */ void ABC_GeneralFreeInfo(tABC_GeneralInfo *pInfo) { if (pInfo) { if ((pInfo->aMinersFees != NULL) && (pInfo->countMinersFees > 0)) { for (unsigned i = 0; i < pInfo->countMinersFees; i++) { ABC_CLEAR_FREE(pInfo->aMinersFees[i], sizeof(tABC_GeneralMinerFee)); } ABC_CLEAR_FREE(pInfo->aMinersFees, sizeof(tABC_GeneralMinerFee *) * pInfo->countMinersFees); } if (pInfo->pAirBitzFee) { ABC_FREE_STR(pInfo->pAirBitzFee->szAddresss); ABC_CLEAR_FREE(pInfo->pAirBitzFee, sizeof(tABC_GeneralMinerFee)); } if ((pInfo->aszObeliskServers != NULL) && (pInfo->countObeliskServers > 0)) { for (unsigned i = 0; i < pInfo->countObeliskServers; i++) { ABC_FREE_STR(pInfo->aszObeliskServers[i]); } ABC_CLEAR_FREE(pInfo->aszObeliskServers, sizeof(char *) * pInfo->countObeliskServers); } if ((pInfo->aszSyncServers != NULL) && (pInfo->countSyncServers > 0)) { for (unsigned i = 0; i < pInfo->countSyncServers; i++) { ABC_FREE_STR(pInfo->aszSyncServers[i]); } ABC_CLEAR_FREE(pInfo->aszSyncServers, sizeof(char *) * pInfo->countSyncServers); } ABC_CLEAR_FREE(pInfo, sizeof(tABC_GeneralInfo)); } }
/** * Generate the QR code for a previously created receive request. * * @param szRequestID ID of this request * @param pszURI Pointer to string to store URI(optional) * @param paData Pointer to store array of data bytes (0x0 white, 0x1 black) * @param pWidth Pointer to store width of image (image will be square) * @param pError A pointer to the location to store the error if there is one */ tABC_CC ABC_TxGenerateRequestQRCode(Wallet &self, const char *szRequestID, char **pszURI, unsigned char **paData, unsigned int *pWidth, tABC_Error *pError) { tABC_CC cc = ABC_CC_Ok; AutoCoreLock lock(gCoreMutex); QRcode *qr = NULL; unsigned char *aData = NULL; unsigned int length = 0; char *szURI = NULL; // load the request/address Address address; ABC_CHECK_NEW(self.addresses.get(address, szRequestID)); // Get the URL string for this info tABC_BitcoinURIInfo infoURI; memset(&infoURI, 0, sizeof(tABC_BitcoinURIInfo)); infoURI.amountSatoshi = address.metadata.amountSatoshi; infoURI.szAddress = address.address.c_str(); // Set the label if there is one ABC_CHECK_RET(ABC_TxBuildFromLabel(self, &(infoURI.szLabel), pError)); // if there is a note if (!address.metadata.notes.empty()) { infoURI.szMessage = address.metadata.notes.c_str(); } ABC_CHECK_RET(ABC_BridgeEncodeBitcoinURI(&szURI, &infoURI, pError)); // encode our string ABC_DebugLog("Encoding: %s", szURI); qr = QRcode_encodeString(szURI, 0, QR_ECLEVEL_L, QR_MODE_8, 1); ABC_CHECK_ASSERT(qr != NULL, ABC_CC_Error, "Unable to create QR code"); length = qr->width * qr->width; ABC_ARRAY_NEW(aData, length, unsigned char); for (unsigned i = 0; i < length; i++) { aData[i] = qr->data[i] & 0x1; } *pWidth = qr->width; *paData = aData; aData = NULL; if (pszURI != NULL) { *pszURI = stringCopy(szURI); } exit: ABC_FREE_STR(szURI); QRcode_free(qr); ABC_CLEAR_FREE(aData, length); return cc; }