Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 950 Lines • ▼ Show 20 Lines | if (batch) { | ||||
batch->WriteOrderPosNext(nOrderPosNext); | batch->WriteOrderPosNext(nOrderPosNext); | ||||
} else { | } else { | ||||
WalletBatch(*database).WriteOrderPosNext(nOrderPosNext); | WalletBatch(*database).WriteOrderPosNext(nOrderPosNext); | ||||
} | } | ||||
return nRet; | return nRet; | ||||
} | } | ||||
bool CWallet::AccountMove(std::string strFrom, std::string strTo, | |||||
const Amount nAmount, std::string strComment) { | |||||
WalletBatch batch(*database); | |||||
if (!batch.TxnBegin()) { | |||||
return false; | |||||
} | |||||
int64_t nNow = GetAdjustedTime(); | |||||
// Debit | |||||
CAccountingEntry debit; | |||||
debit.nOrderPos = IncOrderPosNext(&batch); | |||||
debit.strAccount = strFrom; | |||||
debit.nCreditDebit = -nAmount; | |||||
debit.nTime = nNow; | |||||
debit.strOtherAccount = strTo; | |||||
debit.strComment = strComment; | |||||
AddAccountingEntry(debit, &batch); | |||||
// Credit | |||||
CAccountingEntry credit; | |||||
credit.nOrderPos = IncOrderPosNext(&batch); | |||||
credit.strAccount = strTo; | |||||
credit.nCreditDebit = nAmount; | |||||
credit.nTime = nNow; | |||||
credit.strOtherAccount = strFrom; | |||||
credit.strComment = strComment; | |||||
AddAccountingEntry(credit, &batch); | |||||
return batch.TxnCommit(); | |||||
} | |||||
bool CWallet::GetLabelDestination(CTxDestination &dest, | bool CWallet::GetLabelDestination(CTxDestination &dest, | ||||
const std::string &label, bool bForceNew) { | const std::string &label, bool bForceNew) { | ||||
WalletBatch batch(*database); | WalletBatch batch(*database); | ||||
CAccount account; | CAccount account; | ||||
batch.ReadAccount(label, account); | batch.ReadAccount(label, account); | ||||
if (!bForceNew) { | if (!bForceNew) { | ||||
▲ Show 20 Lines • Show All 4,063 Lines • Show Last 20 Lines |