Improve resolved values for some multisig fns
- createTx resolved pipeline id
- signTx resolves an object {tx_hex, *txid}
- store the message type for multisig pipeline
- Added loadDataFromBlockchain to messenger init fn
- Adding pipeline list to getChatOrder
This commit is contained in:
parent
fcd64fe4d4
commit
a98bf3c589
@ -375,9 +375,12 @@
|
|||||||
.sort((a, b) => b[0] - a[0]).map(a => a[1]);
|
.sort((a, b) => b[0] - a[0]).map(a => a[1]);
|
||||||
result.group = Object.keys(_loaded.groups).map(a => [parseInt(_loaded.appendix[`lastReceived_${a}`]), a])
|
result.group = Object.keys(_loaded.groups).map(a => [parseInt(_loaded.appendix[`lastReceived_${a}`]), a])
|
||||||
.sort((a, b) => b[0] - a[0]).map(a => a[1]);
|
.sort((a, b) => b[0] - a[0]).map(a => a[1]);
|
||||||
|
result.pipeline = Object.keys(_loaded.pipeline).map(a => [parseInt(_loaded.appendix[`lastReceived_${a}`]), a])
|
||||||
|
.sort((a, b) => b[0] - a[0]).map(a => a[1]);
|
||||||
} else {
|
} else {
|
||||||
result = Object.keys(_loaded.chats).map(a => [_loaded.chats[a], a])
|
result = Object.keys(_loaded.chats).map(a => [_loaded.chats[a], a])
|
||||||
.concat(Object.keys(_loaded.groups).map(a => [parseInt(_loaded.appendix[`lastReceived_${a}`]), a]))
|
.concat(Object.keys(_loaded.groups).map(a => [parseInt(_loaded.appendix[`lastReceived_${a}`]), a]))
|
||||||
|
.concat(Object.keys(_loaded.pipeline).map(a => [parseInt(_loaded.appendix[`lastReceived_${a}`]), a]))
|
||||||
.sort((a, b) => b[0] - a[0]).map(a => a[1])
|
.sort((a, b) => b[0] - a[0]).map(a => a[1])
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -909,13 +912,15 @@
|
|||||||
for (let p in data.pipeline)
|
for (let p in data.pipeline)
|
||||||
if (data.pipeline[p].disabled !== true)
|
if (data.pipeline[p].disabled !== true)
|
||||||
requestPipelineInbox(p, data.pipeline[p].model);
|
requestPipelineInbox(p, data.pipeline[p].model);
|
||||||
resolve("Messenger initiated");
|
loadDataFromBlockchain()
|
||||||
|
.then(result => resolve("Messenger initiated"))
|
||||||
|
.catch(error => reject(error))
|
||||||
}).catch(error => reject(error));
|
}).catch(error => reject(error));
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
messenger.loadDataFromBlockchain = function() {
|
const loadDataFromBlockchain = messenger.loadDataFromBlockchain = function() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let user_floID = floCrypto.toFloID(user.id);
|
let user_floID = floCrypto.toFloID(user.id);
|
||||||
if (!user_floID)
|
if (!user_floID)
|
||||||
@ -1027,7 +1032,7 @@
|
|||||||
createPipeline(TYPE_BTC_MULTISIG, co_owners, 32).then(pipeline => {
|
createPipeline(TYPE_BTC_MULTISIG, co_owners, 32).then(pipeline => {
|
||||||
let message = encrypt(tx, pipeline.eKey);
|
let message = encrypt(tx, pipeline.eKey);
|
||||||
sendRaw(message, pipeline.id, "TRANSACTION", false)
|
sendRaw(message, pipeline.id, "TRANSACTION", false)
|
||||||
.then(result => resolve(result))
|
.then(result => resolve(pipeline.id))
|
||||||
.catch(error => reject(error))
|
.catch(error => reject(error))
|
||||||
}).catch(error => reject(error))
|
}).catch(error => reject(error))
|
||||||
}).catch(error => reject(error))
|
}).catch(error => reject(error))
|
||||||
@ -1046,14 +1051,18 @@
|
|||||||
let message = encrypt(tx_hex_signed, pipeline.eKey);
|
let message = encrypt(tx_hex_signed, pipeline.eKey);
|
||||||
sendRaw(message, pipeline.id, "TRANSACTION", false).then(result => {
|
sendRaw(message, pipeline.id, "TRANSACTION", false).then(result => {
|
||||||
if (!btcOperator.checkSigned(tx_hex_signed))
|
if (!btcOperator.checkSigned(tx_hex_signed))
|
||||||
return resolve(tx_hex_signed);
|
return resolve({
|
||||||
|
tx_hex: tx_hex_signed
|
||||||
|
});
|
||||||
debugger;
|
debugger;
|
||||||
btcOperator.broadcast(tx_hex_signed).then(result => {
|
btcOperator.broadcast(tx_hex_signed).then(result => {
|
||||||
let txid = result.txid;
|
let txid = result.txid;
|
||||||
console.debug(txid);
|
console.debug(txid);
|
||||||
sendRaw(encrypt(txid, pipeline.eKey), pipeline.id, "BROADCAST", false)
|
sendRaw(encrypt(txid, pipeline.eKey), pipeline.id, "BROADCAST", false)
|
||||||
.then(result => resolve(txid))
|
.then(result => resolve({
|
||||||
.catch(error => reject(error))
|
tx_hex: tx_hex_signed,
|
||||||
|
txid: txid
|
||||||
|
})).catch(error => reject(error))
|
||||||
}).catch(error => reject(error))
|
}).catch(error => reject(error))
|
||||||
}).catch(error => reject(error))
|
}).catch(error => reject(error))
|
||||||
}).catch(error => console.error(error))
|
}).catch(error => console.error(error))
|
||||||
@ -1174,6 +1183,7 @@
|
|||||||
unparsed.message = decrypt(unparsed.message, k)
|
unparsed.message = decrypt(unparsed.message, k)
|
||||||
//store the pubKey if not stored already
|
//store the pubKey if not stored already
|
||||||
floDapps.storePubKey(unparsed.senderID, unparsed.pubKey);
|
floDapps.storePubKey(unparsed.senderID, unparsed.pubKey);
|
||||||
|
data.type = unparsed.type;
|
||||||
if (unparsed.type === "TRANSACTION") {
|
if (unparsed.type === "TRANSACTION") {
|
||||||
data.message = encrypt(unparsed.message);
|
data.message = encrypt(unparsed.message);
|
||||||
} else if (unparsed.type === "BROADCAST") {
|
} else if (unparsed.type === "BROADCAST") {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user