Chore: refactor generic wallet and wallet plugins
This commit is contained in:
parent
d2b7224c73
commit
b6d91f94bf
11 changed files with 110 additions and 87 deletions
|
|
@ -47,11 +47,12 @@ function accountUnconfirmedBalance (cryptoCode) {
|
|||
|
||||
// We want a balance that includes all spends (0 conf) but only deposits that
|
||||
// have at least 1 confirmation. getbalance does this for us automatically.
|
||||
function balance (account, cryptoCode) {
|
||||
function balance (account, cryptoCode, settings, operatorId) {
|
||||
return accountBalance(cryptoCode)
|
||||
}
|
||||
|
||||
function sendCoins (account, address, cryptoAtoms, cryptoCode) {
|
||||
function sendCoins (account, tx, settings, operatorId) {
|
||||
const { toAddress, cryptoAtoms, cryptoCode } = tx
|
||||
const coins = cryptoAtoms.shift(-unitScale).toFixed(8)
|
||||
const checkSendStatus = function (opid) {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
|
@ -75,7 +76,7 @@ function sendCoins (account, address, cryptoAtoms, cryptoCode) {
|
|||
const checker = opid => pRetry(() => checkSendStatus(opid), { retries: 20, minTimeout: 300, factor: 1.05 })
|
||||
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => fetch('z_sendmany', ['ANY_TADDR', [{ address, amount: coins }]]))
|
||||
.then(() => fetch('z_sendmany', ['ANY_TADDR', [{ toAddress, amount: coins }]]))
|
||||
.then(checker)
|
||||
.then((res) => {
|
||||
return {
|
||||
|
|
@ -95,7 +96,7 @@ function sendCoins (account, address, cryptoAtoms, cryptoCode) {
|
|||
})
|
||||
}
|
||||
|
||||
function newAddress (account, info) {
|
||||
function newAddress (account, info, tx, settings, operatorId) {
|
||||
return checkCryptoCode(info.cryptoCode)
|
||||
.then(() => fetch('getnewaddress'))
|
||||
}
|
||||
|
|
@ -115,7 +116,8 @@ function pendingBalance (address, cryptoCode) {
|
|||
.then(() => addressBalance(address, 0))
|
||||
}
|
||||
|
||||
function getStatus (account, toAddress, requested, cryptoCode) {
|
||||
function getStatus (account, tx, requested, settings, operatorId) {
|
||||
const { toAddress, cryptoCode } = tx
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => confirmedBalance(toAddress, cryptoCode))
|
||||
.then(confirmed => {
|
||||
|
|
@ -130,7 +132,7 @@ function getStatus (account, toAddress, requested, cryptoCode) {
|
|||
})
|
||||
}
|
||||
|
||||
function newFunding (account, cryptoCode) {
|
||||
function newFunding (account, cryptoCode, settings, operatorId) {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => {
|
||||
const promises = [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue