Coin Brief ENDE

xrpl.js now rejects LoanSet and VaultCreate values that rippled rejects in preflight

The JavaScript library xrpl.js merged pull request #3533 on 19 November. It changes validate() so that it rejects the LoanSet and VaultCreate values that rippled already rejects in its preflight checks, and makes flags given as an object, such as { tfLoanOverpayment: true }, work for LoanSet, in Wallet.sign and on the inner transactions of a Batch. According to the pull request, developers at the Lending Protocol hackathon had hit transactions that passed validate() but were rejected by rippled with a bare temINVALID or temMALFORMED.

The pull request lists the gaps field by field. GracePeriod must be between 60 and PaymentInterval, but the library only checked that it did not exceed PaymentInterval, and only when both were set. PaymentTotal and PrincipalRequested must be greater than zero, LoanOriginationFee may not exceed PrincipalRequested, and the eight integer fields of LoanSet must be whole numbers in range - values like 1.5 or NaN previously failed later in the codec. VaultCreate's WithdrawalPolicy must be 1, the first-come-first-served strategy, where any number used to pass.

On flags, LoanSet was missing from the library's flag map, so validate, autofill and sign threw "Invalid flag tfLoanOverpayment", and Wallet.sign did not convert object flags at all. It now converts a copy, leaving the caller's transaction unchanged. The author notes that only values rippled already rejects are newly rejected, and that two error messages changed.

xrpl.js now rejects LoanSet and VaultCreate values that rippled rejects in preflight
xrpl.js now rejects LoanSet and VaultCreate values that rippled rejects in preflight — Coin Brief

Why it matters

A client-side validator is only useful if it agrees with the server: every gap here meant a developer learned about an invalid loan from the ledger rather than from the library.

Primary source
xrpl.js (GitHub)
https://github.com/XRPLF/xrpl.js/pull/3533