Support Strike for Lightning Network
This commit is contained in:
parent
8d4a36865b
commit
3f9c139f83
11 changed files with 175 additions and 11 deletions
40
lib/layer2.js
Normal file
40
lib/layer2.js
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
const configManager = require('./config-manager')
|
||||
const ph = require('./plugin-helper')
|
||||
|
||||
function fetch (settings, cryptoCode) {
|
||||
const plugin = configManager.cryptoScoped(cryptoCode, settings.config).layer2
|
||||
const layer2 = ph.load(ph.LAYER2, plugin)
|
||||
const account = settings.accounts[plugin]
|
||||
|
||||
return Promise.resolve({layer2, account})
|
||||
}
|
||||
|
||||
function newAddress (settings, info) {
|
||||
return fetch(settings, info.cryptoCode)
|
||||
.then(r => r.layer2.newAddress(r.account, info))
|
||||
}
|
||||
|
||||
function getStatus (settings, tx) {
|
||||
return fetch(settings, tx.cryptoCode)
|
||||
.then(r => r.layer2.getStatus(r.account, tx.toAddress, tx.cryptoAtoms, tx.cryptoCode))
|
||||
}
|
||||
|
||||
function cryptoNetwork (settings, cryptoCode) {
|
||||
const plugin = configManager.cryptoScoped(cryptoCode, settings.config).layer2
|
||||
const layer2 = ph.load(ph.LAYER2, plugin)
|
||||
const account = settings.accounts[plugin]
|
||||
|
||||
if (!layer2.cryptoNetwork) return Promise.resolve(false)
|
||||
return layer2.cryptoNetwork(account, cryptoCode)
|
||||
}
|
||||
|
||||
function isLayer2Address (address) {
|
||||
return address.split(':').length >= 2
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
isLayer2Address,
|
||||
newAddress,
|
||||
getStatus,
|
||||
cryptoNetwork
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue