-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
30 lines (23 loc) · 944 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const Litewallet = require('./litewallet');
// const { TxBuilder, PaymentDetect } = require('./utils/utils');
const client = new Litewallet("https://mainnet.lightwalletd.com:9067/", "main");
client.init().then(async ()=> {
console.log("\n\n\n==============\n\n\n")
// Fetch wallet balance
const bal = await client.fetchTotalBalance();
console.log(bal);
// Get all addresses
const addrs = await client.fetchAllAddresses();
console.log(addrs);
// Get addresses with balance
const addrsbal = await client.fetchAddressesWithBalance();
console.log(addrsbal);
// Get last txid
const txid = await client.fetchLastTxId();
console.log(txid);
// Get last transaction details
const tx = await client.getTransactionsList();
const lastTx = tx.filter((t) => t.txid === txid);
console.log(lastTx[0].type);
client.deinitialize();
}).catch((err) => {console.log(err)});