189 const int64_t lPayoutAmount =
192 if (lPayoutAmount <= 0) {
193 OTLog::Output(0,
"PayDividendVisitor::Trigger: nothing to pay, "
194 "since this account owns no shares. (Returning "
200 const OTIdentifier& theServerID = *(
GetServerID());
207 OTPseudonym& theServerNym =
208 const_cast<OTPseudonym&
>(theServer.GetServerNym());
209 const OTIdentifier theServerNymID(theServerNym);
210 const OTIdentifier& RECIPIENT_ID = theSharesAccount.GetUserID();
212 const OTIdentifier& theSenderUserID = *(
GetUserID());
214 const OTString& strMemo = *(
GetMemo());
221 bool bReturnValue =
false;
223 OTCheque theVoucher(theServerID, thePayoutAssetID);
240 int64_t lNewTransactionNumber = 0;
242 bool bGotNextTransNum = theServer.transactor_.issueNextTransactionNumber(
243 theServerNym, lNewTransactionNumber);
249 if (bGotNextTransNum) {
250 const bool bIssueVoucher = theVoucher.IssueCheque(
252 lNewTransactionNumber,
282 theVoucher.SetAsVoucher(theServerNymID, theVoucherAcctID);
283 theVoucher.SignContract(theServerNym);
284 theVoucher.SaveContract();
288 const OTString strVoucher(theVoucher);
289 OTPayment thePayment(strVoucher);
292 bSent = theServer.SendInstrumentToNym(
293 theServerID, theServerNymID,
295 nullptr, &thePayment,
"payDividend");
296 bReturnValue = bSent;
305 const OTString strPayoutAssetID(thePayoutAssetID),
306 strRecipientUserID(RECIPIENT_ID);
308 "issuing voucher (to send to dividend payout "
310 "WAS TRYING TO PAY %ld of asset type %s to Nym %s.\n",
311 lPayoutAmount, strPayoutAssetID.Get(),
312 strRecipientUserID.Get());
318 OTCheque theReturnVoucher(theServerID, thePayoutAssetID);
320 const bool bIssueReturnVoucher = theReturnVoucher.IssueCheque(
322 lNewTransactionNumber,
335 if (bIssueReturnVoucher) {
340 theReturnVoucher.SetAsVoucher(theServerNymID, theVoucherAcctID);
341 theReturnVoucher.SignContract(theServerNym);
342 theReturnVoucher.SaveContract();
347 const OTString strReturnVoucher(theReturnVoucher);
348 OTPayment theReturnPayment(strReturnVoucher);
351 bSent = theServer.SendInstrumentToNym(
352 theServerID, theServerNymID,
354 nullptr, &theReturnPayment,
364 const OTString strPayoutAssetID(thePayoutAssetID),
365 strSenderUserID(theSenderUserID);
367 "failed issuing voucher (to return back to "
368 "the dividend payout initiator, after a failed "
369 "payment attempt to the originally intended "
370 "recipient.) WAS TRYING TO PAY %ld of asset type "
372 lPayoutAmount, strPayoutAssetID.Get(),
373 strSenderUserID.Get());
379 const OTString strPayoutAssetID(thePayoutAssetID),
380 strRecipientUserID(RECIPIENT_ID);
382 "PayDividendVisitor::Trigger: ERROR!! Failed issuing next "
384 "number while trying to send a voucher (while paying dividends.) "
385 "WAS TRYING TO PAY %ld of asset type %s to Nym %s.\n",
386 lPayoutAmount, strPayoutAssetID.Get(), strRecipientUserID.Get());
static EXPORT void vError(const char *szError,...)
static EXPORT void Output(int32_t nVerbosity, const char *szOutput)
time64_t OTTimeAddTimeInterval(time64_t lhs, int64_t rhs)
#define OT_TIME_SIX_MONTHS_IN_SECONDS
time64_t OTTimeGetCurrentTime()
int64_t GetPayoutPerShare()
OTIdentifier * GetUserID()
OTIdentifier * GetVoucherAcctID()
int64_t OTTimeGetSecondsFromTime(time64_t time)
EXPORT OTIdentifier * GetServerID()
OTIdentifier * GetPayoutAssetID()