Merge branch 'release-9.0' into chore/merge-9-into-10-20240214
This commit is contained in:
commit
82acc20b9b
2 changed files with 30 additions and 8 deletions
|
|
@ -152,7 +152,6 @@ function sendProbeRequest (walletId, invoice, cryptoAtoms, token, endpoint) {
|
|||
|
||||
function sendCoins (account, tx, settings, operatorId) {
|
||||
const { toAddress, cryptoAtoms, cryptoCode } = tx
|
||||
const externalCryptoCode = coinUtils.getEquivalentCode(cryptoCode)
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => getGaloyWallet(account.apiSecret, account.endpoint, account.walletId))
|
||||
.then(wallet => {
|
||||
|
|
@ -166,7 +165,7 @@ function sendCoins (account, tx, settings, operatorId) {
|
|||
case 'ALREADY_PAID':
|
||||
throw new Error('Transaction already exists!')
|
||||
case 'FAILURE':
|
||||
throw new Error('Transaction failed!')
|
||||
throw new Error('Transaction failed!', JSON.stringify(result.errors))
|
||||
case 'SUCCESS':
|
||||
return '<galoy transaction>'
|
||||
case 'PENDING':
|
||||
|
|
@ -178,7 +177,7 @@ function sendCoins (account, tx, settings, operatorId) {
|
|||
}
|
||||
|
||||
function probeLN (account, cryptoCode, invoice) {
|
||||
const probeHardLimits = [100, 500, 1000]
|
||||
const probeHardLimits = [200000, 1000000, 2000000]
|
||||
const promises = probeHardLimits.map(limit => {
|
||||
return sendProbeRequest(account.walletId, invoice, limit, account.apiSecret, account.endpoint)
|
||||
.then(r => _.isEmpty(r.errors))
|
||||
|
|
@ -253,6 +252,25 @@ function newAddress (account, info, tx, settings, operatorId) {
|
|||
})
|
||||
}
|
||||
|
||||
function getInvoiceStatus (token, endpoint, address) {
|
||||
const query = {
|
||||
'operationName': 'lnInvoicePaymentStatus',
|
||||
'query': `query lnInvoicePaymentStatus($input: LnInvoicePaymentStatusInput!) {
|
||||
lnInvoicePaymentStatus(input: $input) {
|
||||
status
|
||||
}
|
||||
}`,
|
||||
'variables': {"input": {"paymentRequest": address}}
|
||||
}
|
||||
return request(query, token, endpoint)
|
||||
.then(r => {
|
||||
return r?.data?.lnInvoicePaymentStatus?.status
|
||||
})
|
||||
.catch(err => {
|
||||
throw new Error(err)
|
||||
})
|
||||
}
|
||||
|
||||
function getStatus (account, tx, requested, settings, operatorId) {
|
||||
const { toAddress, cryptoAtoms, cryptoCode } = tx
|
||||
const getBalance = _.reduce((acc, value) => {
|
||||
|
|
@ -260,13 +278,16 @@ function getStatus (account, tx, requested, settings, operatorId) {
|
|||
return acc
|
||||
}, { SUCCESS: new BN(0), PENDING: new BN(0), FAILURE: new BN(0) })
|
||||
|
||||
const externalCryptoCode = coinUtils.getEquivalentCode(cryptoCode)
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => {
|
||||
const address = coinUtils.parseUrl(cryptoCode, account.environment, toAddress, false)
|
||||
// Consider all LN transactions successful
|
||||
if (isLightning(address)) {
|
||||
return { receivedCryptoAtoms: cryptoAtoms, status: 'confirmed' }
|
||||
return getInvoiceStatus(account.apiSecret, account.endpoint, address)
|
||||
.then(it => {
|
||||
const isPaid = it === 'PAID'
|
||||
if (isPaid) return { receivedCryptoAtoms: cryptoAtoms, status: 'confirmed' }
|
||||
return { receivedCryptoAtoms: BN(0), status: 'notSeen' }
|
||||
})
|
||||
}
|
||||
// On-chain and intra-ledger transactions
|
||||
return getTransactionsByAddress(account.apiSecret, account.endpoint, account.walletId, address)
|
||||
|
|
@ -282,7 +303,6 @@ function getStatus (account, tx, requested, settings, operatorId) {
|
|||
}
|
||||
|
||||
function newFunding (account, cryptoCode, settings, operatorId) {
|
||||
const externalCryptoCode = coinUtils.getEquivalentCode(cryptoCode)
|
||||
// Regular BTC address
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => getGaloyWallet(account.apiSecret, account.endpoint, account.walletId))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue