XRPLF / xrpl.js

A JavaScript/TypeScript API for interacting with the XRP Ledger in Node.js and the browser
https://xrpl.org/
1.2k stars 512 forks source link

Check Owner Reserve #1019

Closed cujo30227 closed 5 years ago

cujo30227 commented 5 years ago

When preparing and signing payments, I sometimes get an UNFUNDED_PAYMENT error, even though I'm checking that the sending account has more than the Base Reserve left. I figured that this occurs when the sending account also has additional Owner Reserves.

How can I check the total Reserved XRP on an account before initiating a payment?

Thanks!

tuloski commented 5 years ago

https://xrpl.org/rippleapi-reference.html#getaccountinfo

You can do "ownerCount*5 + 20" to get the amount of reserved XRP.

cujo30227 commented 5 years ago

Cool, thanks! Amazing response time :)

tuloski commented 5 years ago

To be completely safe you can also do a: https://xrpl.org/rippleapi-reference.html#getserverinfo

And instead of using hardcoded 5 and 20 you can use validatedLedger.reserveIncrementXRP and validatedLedger.reserveBaseXRP.

cujo30227 commented 5 years ago

Even better, thanks!