WIP
This commit is contained in:
parent
dde57dfba1
commit
44b46bd5ee
2 changed files with 13 additions and 10 deletions
|
|
@ -298,14 +298,16 @@ function _sendCoinsCb (toAddress, cryptoAtoms, cryptoCode, cb) {
|
|||
}
|
||||
}
|
||||
|
||||
function executeTx (session, tx) {
|
||||
return db.addOutgoingTx(session, tx)
|
||||
// NOTE: This will fail if we have already sent coins because there will be
|
||||
// a db unique db record in the table already.
|
||||
function executeTx (fingerprint, tx) {
|
||||
return db.addOutgoingTx(fingerprint, tx)
|
||||
.then(() => _sendCoins(tx.toAddress, tx.cryptoAtoms, tx.cryptoCode))
|
||||
.then(txHash => {
|
||||
const fee = null // Need to fill this out in plugins
|
||||
const toSend = {cryptoAtoms: tx.cryptoAtoms, fiat: tx.fiat}
|
||||
|
||||
return db.sentCoins(session, tx, toSend, fee, null, txHash)
|
||||
return db.sentCoins(tx, toSend, fee, null, txHash)
|
||||
.then(() => pollBalance(tx.cryptoCode))
|
||||
.then(() => ({
|
||||
statusCode: 201, // Created
|
||||
|
|
@ -358,8 +360,7 @@ exports.recordPing = function recordPing (session, rec, cb) {
|
|||
}
|
||||
|
||||
exports.sendCoins = function sendCoins (session, rawTx) {
|
||||
const _session = {id: rawTx.sessionId || session.id, fingerprint: session.fingerprint}
|
||||
return executeTx(_session, rawTx)
|
||||
return executeTx(session.fingerprint, rawTx)
|
||||
}
|
||||
|
||||
exports.cashOut = function cashOut (session, tx) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue