diff options
author | kumavis <aaron@kumavis.me> | 2016-02-13 09:57:10 +0800 |
---|---|---|
committer | kumavis <aaron@kumavis.me> | 2016-02-13 09:57:10 +0800 |
commit | 970e9e2113e1d78df14fa07f6b3ef9a0c91c4473 (patch) | |
tree | ca80f0956a493f878b7c28e5856a0cf2fd0a850b /app/scripts/lib | |
parent | bc2ec9f464150507f00a7653a4504644853dd666 (diff) | |
download | tangerine-wallet-browser-970e9e2113e1d78df14fa07f6b3ef9a0c91c4473.tar.gz tangerine-wallet-browser-970e9e2113e1d78df14fa07f6b3ef9a0c91c4473.tar.zst tangerine-wallet-browser-970e9e2113e1d78df14fa07f6b3ef9a0c91c4473.zip |
idStore - seperate signTx and sendTx
Diffstat (limited to 'app/scripts/lib')
-rw-r--r-- | app/scripts/lib/idStore.js | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/app/scripts/lib/idStore.js b/app/scripts/lib/idStore.js index 73992caa4..fa5e1fa67 100644 --- a/app/scripts/lib/idStore.js +++ b/app/scripts/lib/idStore.js @@ -105,32 +105,48 @@ IdentityStore.prototype.signTransaction = function(password, txId, cb){ var txData = self._currentState.unconfTxs[txId] var txParams = txData.txParams - self._signTransaction(txParams, function(err, rawTx, txHash){ + self._signTransaction(password, txParams, function(err, rawTx, txHash){ if (err) { - throw err + cb(err) txData.status = 'error' txData.error = err self._didUpdate() return } + txData.rawTx = rawTx txData.hash = txHash - txData.status = 'pending' + txData.status = 'signed' - // for now just remove it - delete self._currentState.unconfTxs[txData.id] - - // rpc callback - var txSigCb = self._unconfTxCbs[txId] || noop - txSigCb(null, rawTx) - - // confirm tx callback + // confirm tx signed cb() - self._didUpdate() }) } +IdentityStore.prototype.sendTransaction = function(txId, cb){ + const self = this + + var txData = self._currentState.unconfTxs[txId] + + if (!txData || txData.status !== 'signed') { + return cb(new Error('IdentityStore - Transaction not signed:', txId)) + } + + var rawTx = txData.rawTx + + // for now just remove it + delete self._currentState.unconfTxs[txData.id] + + // rpc callback + var txSigCb = self._unconfTxCbs[txId] || noop + txSigCb(null, rawTx) + + // confirm tx sent + cb() + self._didUpdate() +} + IdentityStore.prototype.cancelTransaction = function(txId){ const self = this @@ -144,7 +160,7 @@ IdentityStore.prototype.cancelTransaction = function(txId){ // // internal - actually signs the tx -IdentityStore.prototype._signTransaction = function(txParams, cb){ +IdentityStore.prototype._signTransaction = function(password, txParams, cb){ const self = this try { // console.log('signing tx:', txParams) |