@@ -39,7 +39,7 @@ public static function checkAssetDeposit($asset) {
3939 }
4040 $ last_block_number = $ last_block_number - 10 ;
4141 $ depositTxIds = $ service ->findTransfers ($ last_block_number );
42- _log ("Checking $ symbol deposits last_block_number= $ last_block_number deposits: found " . count ($ depositTxIds ));
42+ _log ("$ symbol Checking deposits last_block_number=$ last_block_number deposits: found " . count ($ depositTxIds ));
4343 $ block_height = $ service ->getLastHeight ();
4444 foreach ($ depositTxIds as $ depositTxId ) {
4545 self ::processDepositTxId ($ service , $ asset , $ depositTxId , $ block_height );
@@ -71,28 +71,23 @@ static function processDepositTxId($service, $asset, $depositTxId, $block_height
7171 OfferService::setOfferOpen ($ offer ['id ' ]);
7272 _log ($ asset ['symbol ' ]. " Offer # {$ offer ['id ' ]} Deposit # {$ depositTxId } - set status opened " );
7373 } else {
74- _log ("Not found offer by deposit tx id {$ depositTxId }" );
75- if ($ depositTxId == "0x07fbf96ce3b9e25ccfa09e2511c5e43be9c7f882cad09a51f09a12bdcd296aca " ) {
76- $ a =1 ;
77- }
7874 $ depositTx = $ service ->findTransaction ($ depositTxId );
7975 if (!$ depositTx ) {
80- _log (" Transaction # { $ depositTxId} not found " );
76+ _log ($ asset [ ' symbol ' ]. " Deposit $ depositTxId not found " );
8177 return ;
8278 }
8379 $ amount = $ depositTx ['amount ' ];
8480 $ offers = OfferService::getOfferByDepositAmount (floatval ($ amount ), $ asset ['id ' ]);
85- _log ("Found offers by amount {$ amount }: found " . count ($ offers ));
8681 if (count ($ offers )>1 ) {
87- _log (" Multiple offers found for amount $ amount " );
82+ _log ($ asset [ ' symbol ' ]. " Deposit $ depositTxId - Multiple offers found for amount $ amount " );
8883 return ;
8984 }
9085 if (count ($ offers )==0 ) {
91- _log (" No offer found for amount $ amount " );
86+ _log ($ asset [ ' symbol ' ]. " Deposit $ depositTxId - No offer found for amount $ amount " );
9287 return ;
9388 }
9489 $ offer = $ offers [0 ];
95- _log (" Set offer # {$ offer ['id ' ]} deposition for # { $ depositTxId } " );
90+ _log ($ asset [ ' symbol ' ]. " Deposit $ depositTxId - amount $ amount - found offer # {$ offer ['id ' ]} - set status depositing " );
9691 OfferService::setOfferDepositing ($ offer ['id ' ], $ depositTxId );
9792 }
9893 }
@@ -164,19 +159,18 @@ public static function checkAssetTransferring($asset)
164159 _log ("Transaction check failed " );
165160 continue ;
166161 }
167- _log ("No offer found for transfer transaction $ txId - looking for amount $ amount " );
168162 $ offers = OfferService::getAcceptedOfferByAmount ($ amount , $ asset ['id ' ]);
169163 if (count ($ offers )>1 ) {
170- _log (" Found multiple offers for $ amount " );
164+ _log ($ asset [ ' symbol ' ] . " Found multiple offers for $ amount " );
171165 continue ;
172166 }
173167 if (count ($ offers )==0 ) {
174- _log (" No offer found for amount $ amount " );
168+ _log ($ asset [ ' symbol ' ] . " No offer found for amount $ amount " );
175169 continue ;
176170 }
177171 $ offer = $ offers [0 ];
178- _log ("Found offer # {$ offer ['id ' ]} for transfer transaction $ txId " );
179172 OfferService::setAcceptedOfferTransferring ($ offer ['id ' ], $ txId );
173+ _log ($ asset ['symbol ' ]." Found offer # {$ offer ['id ' ]} for transfer transaction $ txId - set status transferring " );
180174 }
181175 }
182176 }
@@ -312,4 +306,25 @@ public static function checkIncompleteTransferLogs()
312306 OfferService::updateTransferLogWithTransaction ($ log ['id ' ], $ tx );
313307 }
314308 }
309+
310+ public static function returnDeposit (string $ symbol , string $ deposit_tx_id )
311+ {
312+ _log ("$ symbol Return deposit tx $ deposit_tx_id " );
313+ $ asset = OfferService::getAssetBySymbol ($ symbol );
314+ $ service = OfferService::getService ($ asset ['service ' ]);
315+ $ tx = $ service ->findTransaction ($ deposit_tx_id );
316+ if (!$ tx ) {
317+ _log ("$ symbol Not found transaction $ deposit_tx_id " );
318+ return ;
319+ }
320+ if ($ tx ['to ' ] != $ service ->getEscrowAddress ()) {
321+ _log ("$ symbol transaction $ deposit_tx_id - not deposit tx " );
322+ return ;
323+ }
324+ $ amount = $ tx ['amount ' ];
325+ $ dst = $ tx ['from ' ];
326+ _log ("$ symbol Return deposit tx $ deposit_tx_id amount = $ amount to = $ dst " );
327+ $ hash = $ service ->createPayment ($ amount , $ dst , null );
328+ _log ("$ symbol Return deposit tx $ deposit_tx_id - created transaction $ hash " );
329+ }
315330}
0 commit comments