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 510 forks source link

How can I get Block from ledger and Destination Tag ? #1349

Closed prodevcn closed 3 years ago

prodevcn commented 3 years ago

get block form ledger

I am working on ripple-lib to create small exchange platform. For this, I assigned an address to an user and developed depositor daemon. This daemon will work like follows.

1. get block from ledger in loop circle.
2. get transaction info from block.
3. compare user's address with addresses from transactions.
4. if they are equal, save transaction info to database, else, repeat 1-4

In case of other cryptocurrencies, core API supports getblock, gettransactionfromblock, etc. But, I can't find them in XRP guide - https://xrpl.org/ How can I do this ?

Destination Tag

I am going to assign same address and other destination tag to every user. For this, I need to add destination tag to XRP account. I used generateAddress() ripple-lib api. Response result like follow :

{
    "xAddress": "X7q8qo2MqxgTUxgRyjUedY6ZHAq2PePZugC3SopTfEtJGFU",
    "secret": "shuRCHJJDyHFH5ZJ4Yj2K5eXvNtx7",
    "classicAddress": "rfFtbn1btswLQZ2VTGy2Lo72HRCfMd9hFi",
    "address": "rfFtbn1btswLQZ2VTGy2Lo72HRCfMd9hFi"
}

How can I do this ?

tuloski commented 3 years ago

First of all in XRPL the block is called a "ledger". You can retrieve all the information on the ledger in different ways, but it depends on what you are interested in. About the listening transactions of a user you can do in multiple ways: