txId bug fixes; debugging
This commit is contained in:
parent
572bd7a10f
commit
3d9c95ba7f
4 changed files with 20 additions and 11 deletions
|
|
@ -276,6 +276,7 @@ exports.pollQueries = function pollQueries (deviceId) {
|
|||
function _sendCoins (toAddress, cryptoAtoms, cryptoCode) {
|
||||
return new Promise((resolve, reject) => {
|
||||
_sendCoinsCb(toAddress, cryptoAtoms, cryptoCode, (err, txHash) => {
|
||||
console.log('DEBUG12: %j, %j', err, txHash)
|
||||
if (err) return reject(err)
|
||||
return resolve(txHash)
|
||||
})
|
||||
|
|
@ -297,9 +298,12 @@ function _sendCoinsCb (toAddress, cryptoAtoms, cryptoCode, cb) {
|
|||
// 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 (deviceId, tx) {
|
||||
console.log('DEBUG16: %j', tx)
|
||||
return db.addOutgoingTx(deviceId, tx)
|
||||
.then(() => _sendCoins(tx.toAddress, tx.cryptoAtoms, tx.cryptoCode))
|
||||
.then(txHash => {
|
||||
console.log('DEBUG13: %j', txHash)
|
||||
|
||||
const fee = null // Need to fill this out in plugins
|
||||
const toSend = {cryptoAtoms: tx.cryptoAtoms, fiat: tx.fiat}
|
||||
|
||||
|
|
@ -308,7 +312,7 @@ function executeTx (deviceId, tx) {
|
|||
.then(() => ({
|
||||
statusCode: 201, // Created
|
||||
txHash,
|
||||
txId: tx.txId
|
||||
txId: tx.id
|
||||
}))
|
||||
})
|
||||
}
|
||||
|
|
@ -355,8 +359,8 @@ exports.recordPing = function recordPing (deviceId, deviceTime, rec, cb) {
|
|||
return db.machineEvent(event)
|
||||
}
|
||||
|
||||
exports.sendCoins = function sendCoins (rawTx) {
|
||||
return executeTx(rawTx)
|
||||
exports.sendCoins = function sendCoins (deviceId, rawTx) {
|
||||
return executeTx(deviceId, rawTx)
|
||||
}
|
||||
|
||||
exports.cashOut = function cashOut (deviceId, tx) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue