@psf/bch-js 6.2.0 → 6.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/transaction.js +40 -1
package/package.json
CHANGED
package/src/transaction.js
CHANGED
|
@@ -20,11 +20,50 @@ class Transaction {
|
|
|
20
20
|
this.psfSlpIndexer = new PsfSlpIndexer(config)
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
/**
|
|
24
|
+
* @api Transaction.get() get()
|
|
25
|
+
* @apiName get
|
|
26
|
+
* @apiGroup Transaction
|
|
27
|
+
* @apiDescription
|
|
28
|
+
* Returns an object of transaction data, including addresses for input UTXOs.
|
|
29
|
+
* If it is a SLP token transaction, the token information for inputs and
|
|
30
|
+
* outputs will also be included.
|
|
31
|
+
*
|
|
32
|
+
*
|
|
33
|
+
* @apiExample Example usage:
|
|
34
|
+
* (async () => {
|
|
35
|
+
* try {
|
|
36
|
+
* let txData = await bchjs.Transaction.get("0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098");
|
|
37
|
+
* console.log(txData);
|
|
38
|
+
* } catch(error) {
|
|
39
|
+
* console.error(error)
|
|
40
|
+
* }
|
|
41
|
+
* })()
|
|
42
|
+
*/
|
|
24
43
|
async get (txid) {
|
|
25
44
|
return await this.psfSlpIndexer.tx(txid)
|
|
26
45
|
}
|
|
27
46
|
|
|
47
|
+
/**
|
|
48
|
+
* @api Transaction.getTokenInfo() getTokenInfo()
|
|
49
|
+
* @apiName getTokenInfo
|
|
50
|
+
* @apiGroup Transaction
|
|
51
|
+
* @apiDescription
|
|
52
|
+
* Given the TXID of a token transaction, it will return data about that
|
|
53
|
+
* token by retrieving the data from the Genesis transaction and docoding
|
|
54
|
+
* the OP_RETURN.
|
|
55
|
+
*
|
|
56
|
+
*
|
|
57
|
+
* @apiExample Example usage:
|
|
58
|
+
* (async () => {
|
|
59
|
+
* try {
|
|
60
|
+
* let txData = await bchjs.Transaction.getTokenInfo("0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098");
|
|
61
|
+
* console.log(txData);
|
|
62
|
+
* } catch(error) {
|
|
63
|
+
* console.error(error)
|
|
64
|
+
* }
|
|
65
|
+
* })()
|
|
66
|
+
*/
|
|
28
67
|
// A wrapper for decodeOpReturn(). Returns false if txid is not an SLP tx.
|
|
29
68
|
// Returns the token data if the txid is an SLP tx.
|
|
30
69
|
async getTokenInfo (txid) {
|