feat: wallet plugin structure
This commit is contained in:
parent
06e6b2f657
commit
12ef86ebbf
3 changed files with 61 additions and 0 deletions
61
lib/plugins/wallet/lightning/galoy.js
Normal file
61
lib/plugins/wallet/lightning/galoy.js
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
const BN = require('../../../bn')
|
||||
|
||||
const NAME = 'LN'
|
||||
const SUPPORTED_COINS = ['BTC']
|
||||
|
||||
function checkCryptoCode (cryptoCode) {
|
||||
if (!SUPPORTED_COINS.includes(cryptoCode)) {
|
||||
return Promise.reject(new Error('Unsupported crypto: ' + cryptoCode))
|
||||
}
|
||||
|
||||
return Promise.resolve()
|
||||
}
|
||||
|
||||
function getWallet () {
|
||||
// Create wallet instance
|
||||
}
|
||||
|
||||
function sendCoins (account, tx, settings, operatorId) {
|
||||
// const { toAddress, cryptoAtoms, cryptoCode } = tx
|
||||
return {}
|
||||
}
|
||||
|
||||
function balance (account, cryptoCode, settings, operatorId) {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => getWallet(account, cryptoCode))
|
||||
.then(wallet => new BN(wallet._wallet.spendableBalanceString))
|
||||
}
|
||||
|
||||
function newAddress (account, info, tx, settings, operatorId) {
|
||||
return checkCryptoCode(info.cryptoCode)
|
||||
}
|
||||
|
||||
function getStatus (account, tx, requested, settings, operatorId) {
|
||||
const { cryptoCode } = tx
|
||||
return checkCryptoCode(cryptoCode).then(() => {})
|
||||
}
|
||||
|
||||
function newFunding (account, cryptoCode, settings, operatorId) {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
}
|
||||
|
||||
function cryptoNetwork (account, cryptoCode, settings, operatorId) {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => account.environment === 'test' ? 'test' : 'main')
|
||||
}
|
||||
|
||||
function checkBlockchainStatus (cryptoCode) {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => Promise.resolve('ready'))
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
NAME,
|
||||
balance,
|
||||
sendCoins,
|
||||
newAddress,
|
||||
getStatus,
|
||||
newFunding,
|
||||
cryptoNetwork,
|
||||
checkBlockchainStatus
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue