aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2016-02-13 09:57:10 +0800
committerkumavis <aaron@kumavis.me>2016-02-13 09:57:10 +0800
commit970e9e2113e1d78df14fa07f6b3ef9a0c91c4473 (patch)
treeca80f0956a493f878b7c28e5856a0cf2fd0a850b /app
parentbc2ec9f464150507f00a7653a4504644853dd666 (diff)
downloadtangerine-wallet-browser-970e9e2113e1d78df14fa07f6b3ef9a0c91c4473.tar
tangerine-wallet-browser-970e9e2113e1d78df14fa07f6b3ef9a0c91c4473.tar.gz
tangerine-wallet-browser-970e9e2113e1d78df14fa07f6b3ef9a0c91c4473.tar.bz2
tangerine-wallet-browser-970e9e2113e1d78df14fa07f6b3ef9a0c91c4473.tar.lz
tangerine-wallet-browser-970e9e2113e1d78df14fa07f6b3ef9a0c91c4473.tar.xz
tangerine-wallet-browser-970e9e2113e1d78df14fa07f6b3ef9a0c91c4473.tar.zst
tangerine-wallet-browser-970e9e2113e1d78df14fa07f6b3ef9a0c91c4473.zip
idStore - seperate signTx and sendTx
Diffstat (limited to 'app')
-rw-r--r--app/scripts/background.js1
-rw-r--r--app/scripts/lib/idStore.js42
2 files changed, 30 insertions, 13 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js
index 6a1b7404f..53acaa290 100644
--- a/app/scripts/background.js
+++ b/app/scripts/background.js
@@ -80,6 +80,7 @@ function handleInternalCommunication(remotePort){
setSelectedAddress: idStore.setSelectedAddress.bind(idStore),
signTransaction: idStore.signTransaction.bind(idStore),
cancelTransaction: idStore.cancelTransaction.bind(idStore),
+ sendTransaction: idStore.sendTransaction.bind(idStore),
setLocked: idStore.setLocked.bind(idStore),
})
duplex.pipe(connection).pipe(duplex)
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)