Created
September 22, 2025 17:08
-
-
Save gayleQN/3e7224de37d35ea923d7b9cb53826656 to your computer and use it in GitHub Desktop.
XRPL Wallet Monitor filter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Returns { matchingTransactions } or null | |
| const CONFIG = { | |
| Wallets: [ | |
| 'rEmnE8iCKY21cesiywotSDoQgTyaNAvgYX', | |
| ], | |
| }; | |
| function main(payload) { | |
| const wallets = new Set(CONFIG.Wallets); | |
| const matchingTransactions = []; | |
| const getDeliveredAmount = (tx) => | |
| (tx?.metaData?.delivered_amount ?? | |
| tx?.metaData?.DeliveredAmount ?? | |
| tx?.Amount ?? null); | |
| for (const item of (payload?.data || [])) { | |
| const ledger = item.ledger || {}; | |
| for (const tx of (ledger.transactions || [])) { | |
| if (tx.TransactionType !== 'Payment' || !tx.Account || !tx.Destination || !tx.metaData) { | |
| continue; | |
| } | |
| if (tx.metaData.TransactionResult !== 'tesSUCCESS') continue; | |
| if (!wallets.has(tx.Account) && !wallets.has(tx.Destination)) continue; | |
| const delivered = getDeliveredAmount(tx); | |
| if (delivered === null) continue; | |
| matchingTransactions.push(tx); | |
| } | |
| } | |
| return matchingTransactions.length ? { matchingTransactions } : null; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment