Skip to content

Instantly share code, notes, and snippets.

@gayleQN
Created September 22, 2025 17:08
Show Gist options
  • Select an option

  • Save gayleQN/3e7224de37d35ea923d7b9cb53826656 to your computer and use it in GitHub Desktop.

Select an option

Save gayleQN/3e7224de37d35ea923d7b9cb53826656 to your computer and use it in GitHub Desktop.
XRPL Wallet Monitor filter
// 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