Skip to content

Commit

Permalink
PaymentChannelFund fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
zgrguric committed Nov 28, 2023
1 parent bcad5c5 commit f36c68a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
30 changes: 20 additions & 10 deletions app/XRPLParsers/Types/PaymentChannelFund.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
namespace App\XRPLParsers\Types;

use App\XRPLParsers\XRPLParserBase;
use XRPLWin\XRPLTxParticipantExtractor\TxParticipantExtractor;

final class PaymentChannelFund extends XRPLParserBase
{
private array $acceptedParsedTypes = ['SENT','UNKNOWN'];
private array $acceptedParsedTypes = ['SENT','REGULARKEYSIGNER','UNKNOWN'];

/**
* Parses TrustSet type fields and maps them to $this->data
Expand All @@ -23,6 +24,8 @@ protected function parseTypeFields(): void
throw new \Exception('Unhandled parsedType ['.$parsedType.'] on PaymentChannelFund with HASH ['.$this->data['hash'].'] and perspective ['.$this->reference_address.']');

$this->data['Counterparty'] = $this->tx->Account;
$this->data['In'] = false;


//Counterparty is found in PayChannel Modified node
if($this->reference_address == $this->tx->Account) {
Expand All @@ -35,15 +38,23 @@ protected function parseTypeFields(): void
}
}
}

//Fund is always out
$this->data['In'] = false;

/*if($this->reference_address == $this->tx->Account) {
$this->data['In'] = false;
} else {
$this->data['In'] = false;
}*/
$participants = new TxParticipantExtractor($this->tx);
$participants = $participants->accounts();
foreach($participants as $pacc => $proles) {
if($this->reference_address == $pacc) {
if(\in_array('PAYCHANNEL_DESTINATION',$proles)) {
$this->data['In'] = true;
}
break;
}
}

if(!isset($participants[$this->reference_address]))
$this->persist = false;
else if($parsedType == 'REGULARKEYSIGNER') {
$this->persist = false;
}

# Balance changes from eventList (primary/secondary, both, one, or none)
if(isset($this->data['eventList']['primary'])) {
Expand All @@ -52,7 +63,6 @@ protected function parseTypeFields(): void
throw new \Exception('Unhandled non XRP value on PaymentChannelFund with HASH ['.$this->data['hash'].'] and perspective ['.$this->reference_address.']');
}
}

}

/**
Expand Down
3 changes: 2 additions & 1 deletion documentation/todos.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,5 @@ rBgyjCQLVdSHwKVAhCZNTbmDsFHqLkzZdw
https://bithomp.com/explorer/rHwtsaA1X4mzVCEqcvEvk59uRLhVos9xnZ


Thu Mar 01 2018 04:36:11 ( 36,908,569 ) is ledger when excrowfinish handling is fixed, potentially escrowfinish txs before that ledgers are wrong.
Thu Mar 01 2018 04:36:11 ( 36,908,569 ) is ledger when excrowfinish handling is fixed, potentially escrowfinish txs before that ledgers are wrong.
Tue Aug 28 2018 08:47:31 GMT+0200 ( 41,115,569 ) is ledger when PaymentChannelFund fixed bug when recieving accounts has isin = false (now isin = true)

0 comments on commit f36c68a

Please sign in to comment.