Multisig signTx improvement

- multisig.signTx no longer require tx_hex as argument.
- automatically get the latest available tx_hex from IDB (pipeline chat)
This commit is contained in:
sairajzero 2022-08-16 22:03:18 +05:30
parent b8b58503f6
commit fcd64fe4d4

View File

@ -1034,25 +1034,29 @@
}) })
} }
MultiSig.signTx = function(pipeID, tx_hex) { MultiSig.signTx = function(pipeID) {
return new Promise(async (resolve, reject) => { return new Promise((resolve, reject) => {
let pipeline = _loaded.pipeline[pipeID], if (_loaded.pipeline[pipeID].disabled)
tx = coinjs.transaction().deserialize(tx_hex);; return reject("Pipeline is already closed");
let privateKey = await floDapps.user.private; getChat(pipeID).then(async result => {
tx_hex = btcOperator.signTx(tx, privateKey); let pipeline = _loaded.pipeline[pipeID],
let message = encrypt(tx_hex, pipeline.eKey); tx_hex_latest = Object.keys(result).sort().map(i => result[i].message).filter(x => x).pop();
sendRaw(message, pipeline.id, "TRANSACTION", false).then(result => { let privateKey = await floDapps.user.private;
if (!btcOperator.checkSigned(tx)) let tx_hex_signed = btcOperator.signTx(tx_hex_latest, privateKey);
return resolve(tx_hex); let message = encrypt(tx_hex_signed, pipeline.eKey);
debugger; sendRaw(message, pipeline.id, "TRANSACTION", false).then(result => {
btcOperator.broadcast(tx_hex).then(result => { if (!btcOperator.checkSigned(tx_hex_signed))
let txid = result.txid; return resolve(tx_hex_signed);
console.debug(txid); debugger;
sendRaw(encrypt(txid, pipeline.eKey), pipeline.id, "BROADCAST", false) btcOperator.broadcast(tx_hex_signed).then(result => {
.then(result => resolve(txid)) let txid = result.txid;
.catch(error => reject(error)) console.debug(txid);
sendRaw(encrypt(txid, pipeline.eKey), pipeline.id, "BROADCAST", false)
.then(result => resolve(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))
}) })
} }