This repository has been archived by the owner on Jul 16, 2020. It is now read-only.
/
quick-testing.js
66 lines (52 loc) · 2.48 KB
/
quick-testing.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// const Wallet = require('.').default
const { Wallet } = require('.')
console.log(Wallet)
const seed = 'attend ordinary entire myth leg utility flat jacket trade smart despair clerk'
const run = async () => {
const wallet = new Wallet('BITCOIN_ELECTRUM_BIP39', { seed }, { network: 'testnet' })
/*
const amount = Wallet.convert(4321, 'sat')
console.log(Wallet.convert(1, 'bitcoins').toFactor(8888))
console.log(Wallet.convert(1234, 'sat').to('btc'))
console.log(Wallet.convert(1, 'deca').toFactor(8888))
console.log(Wallet.convert(8888, 'mBTC').to('bits'))
console.log(Wallet.convert(1234, 'sat').to('mbtc'))
console.log(Wallet.convert(1234, 'sat').to('MBTC'))
console.log(amount.to('MBTC'))
console.log(amount.to('mBTC'))
console.log(amount.to('msat'))
console.log(amount.to('deca'))
console.log(amount.to('dabtc'))
console.log(Wallet.convert(8, 'msat').to('MBTC'))
console.log(Wallet.convert(5, 'bitcoins').toFactor(1e-4))
console.log(Wallet.convert(1, 'btc').to('euro'))
console.log(Wallet.convert(0.01, 'btc').to('euro'))
console.log(Wallet.convert(1000, 'sat').to('euro'))
console.log(Wallet.convert(1, 'sat').to('euro'))
*/
await wallet.ready()
console.log(Object.keys(wallet))
console.log(wallet._bip32Wallet.mainAccount._external.map(x => x.id))
console.log(wallet._bip32Wallet.mainAccount._change.map(x => x.id))
// console.log(wallet.getTransactions().find(x => x.hash === 'd7617db9c2e5957a3a7cf82310d051590259f12619c5a4ef21ff6b00c594af32'))
// console.log(wallet.getTransactions().map(x => x.height))
// console.log(wallet._bip32Wallet.mainAccount._external.map(x => `${x.id}, history: ${!!x.history.length}`))
// console.log(wallet.getReceiveAddress())
// console.log(wallet._bip32Wallet)
// console.log(wallet)
/*
const prettyLog = x => console.log(`Direction: ${x.direction}, amount: ${x.amount}${
x.feePaidByWallet ? `, fee: ${x.fee}` : ''}, total: ${x.total}`)
wallet.alerts.on('transaction', prettyLog)
wallet.alerts.on('balance', console.log)
wallet.alerts.on('ready', () => console.log('ready!!!!!!!!!'))
await wallet.onReady()
console.log(await wallet.getBalance())
console.log(await wallet.getBalance({ unit: 'satoshis' }))
/*
const {type, index} = wallet._getAddressLocationFromId('mq7CETgVeRkrh7GtSvMZVWbbo3ANBnk9mM')
console.log(wallet._addresses.external.map(x => x.id))
console.log(wallet._transactions['2b12eaac53c3ea9be3349ac57e89c31e4f20656afb0a2972b09bf8a2229b7a56'])
*/
}
run().catch(console.error)