Chore: refactor generic wallet and wallet plugins

This commit is contained in:
csrapr 2021-03-16 18:41:44 +00:00 committed by Josh Harvey
parent d2b7224c73
commit b6d91f94bf
11 changed files with 110 additions and 87 deletions

View file

@ -23,7 +23,7 @@ function connect () {
return lnd.connect(options.lnd || {})
}
function cryptoNetwork (account, cryptoCode) {
function cryptoNetwork (account, cryptoCode, settings, operatorId) {
return Promise.resolve('main')
}
@ -32,7 +32,7 @@ function checkCryptoCode (cryptoCode) {
return Promise.resolve()
}
function balance (acount, cryptoCode) {
function balance (acount, cryptoCode, settings, operatorId) {
return checkCryptoCode(cryptoCode)
.then(connect)
.then(c => c.channelBalance({}))
@ -41,17 +41,18 @@ function balance (acount, cryptoCode) {
.then(r => r.shift(unitScale).round())
}
function sendCoins (account, address, cryptoAtoms, cryptoCode) {
function sendCoins (account, tx, settings, operatorId) {
// const { toAddress, cryptoAtoms, cryptoCode } = tx
// Not implemented yet
return Promise.reject(new E.NotImplementedError())
}
function newFunding (account, cryptoCode) {
function newFunding (account, cryptoCode, settings, operatorId) {
// Not implemented yet
return Promise.reject(new E.NotImplementedError())
}
function newAddress (account, info) {
function newAddress (account, info, tx, settings, operatorId) {
return checkCryptoCode(info.cryptoCode)
.then(connect)
.then(c => {
@ -65,7 +66,8 @@ function newAddress (account, info) {
})
}
function getStatus (account, toAddress, requested, cryptoCode) {
function getStatus (account, tx, requested, settings, operatorId) {
const { toAddress, cryptoCode } = tx
return checkCryptoCode(cryptoCode)
.then(() => {
const parts = _.split(':', toAddress)
@ -74,10 +76,10 @@ function getStatus (account, toAddress, requested, cryptoCode) {
return connect()
.then(c => {
return c.lookupInvoice({r_hash_str: rHashStr})
return c.lookupInvoice({ r_hash_str: rHashStr })
.then(r => {
if (r.settled) return {status: 'confirmed'}
return {status: 'notSeen'}
if (r.settled) return { status: 'confirmed' }
return { status: 'notSeen' }
})
})
})