mirror of
https://github.com/Permissionless-Software-Foundation/bch-js.git
synced 2026-09-21 16:51:59 -07:00
Merge pull request #222 from Permissionless-Software-Foundation/ct-unstable
Adding API docs for Transaction lib
This commit is contained in:
+40
-1
@@ -20,11 +20,50 @@ class Transaction {
|
|||||||
this.psfSlpIndexer = new PsfSlpIndexer(config)
|
this.psfSlpIndexer = new PsfSlpIndexer(config)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Proxy the call to the psf-slp-indexer.
|
/**
|
||||||
|
* @api Transaction.get() get()
|
||||||
|
* @apiName get
|
||||||
|
* @apiGroup Transaction
|
||||||
|
* @apiDescription
|
||||||
|
* Returns an object of transaction data, including addresses for input UTXOs.
|
||||||
|
* If it is a SLP token transaction, the token information for inputs and
|
||||||
|
* outputs will also be included.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @apiExample Example usage:
|
||||||
|
* (async () => {
|
||||||
|
* try {
|
||||||
|
* let txData = await bchjs.Transaction.get("0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098");
|
||||||
|
* console.log(txData);
|
||||||
|
* } catch(error) {
|
||||||
|
* console.error(error)
|
||||||
|
* }
|
||||||
|
* })()
|
||||||
|
*/
|
||||||
async get (txid) {
|
async get (txid) {
|
||||||
return await this.psfSlpIndexer.tx(txid)
|
return await this.psfSlpIndexer.tx(txid)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @api Transaction.getTokenInfo() getTokenInfo()
|
||||||
|
* @apiName getTokenInfo
|
||||||
|
* @apiGroup Transaction
|
||||||
|
* @apiDescription
|
||||||
|
* Given the TXID of a token transaction, it will return data about that
|
||||||
|
* token by retrieving the data from the Genesis transaction and docoding
|
||||||
|
* the OP_RETURN.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @apiExample Example usage:
|
||||||
|
* (async () => {
|
||||||
|
* try {
|
||||||
|
* let txData = await bchjs.Transaction.getTokenInfo("0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098");
|
||||||
|
* console.log(txData);
|
||||||
|
* } catch(error) {
|
||||||
|
* console.error(error)
|
||||||
|
* }
|
||||||
|
* })()
|
||||||
|
*/
|
||||||
// A wrapper for decodeOpReturn(). Returns false if txid is not an SLP tx.
|
// A wrapper for decodeOpReturn(). Returns false if txid is not an SLP tx.
|
||||||
// Returns the token data if the txid is an SLP tx.
|
// Returns the token data if the txid is an SLP tx.
|
||||||
async getTokenInfo (txid) {
|
async getTokenInfo (txid) {
|
||||||
|
|||||||
Reference in New Issue
Block a user