Fix: multisig createTx not working properly
- Fixed: multisig createTx throwing error Invalid Members (pubKey not available) when members try to create it
This commit is contained in:
parent
1b8cf04dcd
commit
4d6ecd0a35
@ -1170,7 +1170,7 @@
|
|||||||
let privateKey = await floDapps.user.private;
|
let privateKey = await floDapps.user.private;
|
||||||
btcOperator.createMultiSigTx(address, redeemScript, receivers, amounts, fee, options).then(({ tx_hex }) => {
|
btcOperator.createMultiSigTx(address, redeemScript, receivers, amounts, fee, options).then(({ tx_hex }) => {
|
||||||
tx_hex = btcOperator.signTx(tx_hex, privateKey);
|
tx_hex = btcOperator.signTx(tx_hex, privateKey);
|
||||||
createPipeline(TYPE_BTC_MULTISIG, co_owners, 32).then(pipeline => {
|
createPipeline(TYPE_BTC_MULTISIG, co_owners, 32, decode.pubkeys).then(pipeline => {
|
||||||
let message = encrypt(tx_hex, pipeline.eKey);
|
let message = encrypt(tx_hex, pipeline.eKey);
|
||||||
sendRaw(message, pipeline.id, "TRANSACTION", false)
|
sendRaw(message, pipeline.id, "TRANSACTION", false)
|
||||||
.then(result => resolve(pipeline.id))
|
.then(result => resolve(pipeline.id))
|
||||||
@ -1232,7 +1232,7 @@
|
|||||||
let privateKey = await floDapps.user.private;
|
let privateKey = await floDapps.user.private;
|
||||||
floBlockchainAPI.createMultisigTx(redeemScript, receivers, amounts, floData).then(tx_hex => {
|
floBlockchainAPI.createMultisigTx(redeemScript, receivers, amounts, floData).then(tx_hex => {
|
||||||
tx_hex = floBlockchainAPI.signTx(tx_hex, privateKey);
|
tx_hex = floBlockchainAPI.signTx(tx_hex, privateKey);
|
||||||
createPipeline(TYPE_FLO_MULTISIG, co_owners, 32).then(pipeline => {
|
createPipeline(TYPE_FLO_MULTISIG, co_owners, 32, decode.pubkeys).then(pipeline => {
|
||||||
let message = encrypt(tx_hex, pipeline.eKey);
|
let message = encrypt(tx_hex, pipeline.eKey);
|
||||||
sendRaw(message, pipeline.id, "TRANSACTION", false)
|
sendRaw(message, pipeline.id, "TRANSACTION", false)
|
||||||
.then(result => resolve(pipeline.id))
|
.then(result => resolve(pipeline.id))
|
||||||
@ -1273,16 +1273,29 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Pipelines
|
//Pipelines
|
||||||
const createPipeline = function (model, members, ekeySize = 16) {
|
const createPipeline = function (model, members, ekeySize = 16, pubkeys = null) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
//optional pubkey parameter
|
||||||
|
if (pubkeys !== null) {
|
||||||
|
if (!Array.isArray(pubkeys))
|
||||||
|
return reject('pubkeys must be an array (if passed)');
|
||||||
|
else if (pubkeys.length !== members.length)
|
||||||
|
return reject('pubkey length doesnot match members length');
|
||||||
|
}
|
||||||
|
|
||||||
//validate members
|
//validate members
|
||||||
let imem1 = [],
|
let imem1 = [],
|
||||||
imem2 = []
|
imem2 = []
|
||||||
members.forEach(m =>
|
members.forEach((m, i) => {
|
||||||
!floCrypto.validateAddr(m) ? imem1.push(m) :
|
if (!floCrypto.validateAddr(m))
|
||||||
m in floGlobals.pubKeys ? null :
|
imem1.push(m);
|
||||||
m != user.id ? imem2.push(m) : null
|
else if (!(m in floGlobals.pubKeys) && m != user.id) {
|
||||||
);
|
if (pubkeys !== null && floCrypto.verifyPubKey(pubkeys[i], m))
|
||||||
|
floGlobals.pubKeys[m] = pubkeys[i];
|
||||||
|
else
|
||||||
|
imem2.push(m);
|
||||||
|
}
|
||||||
|
});
|
||||||
if (imem1.length)
|
if (imem1.length)
|
||||||
return reject(`Invalid Members(floIDs): ${imem1}`);
|
return reject(`Invalid Members(floIDs): ${imem1}`);
|
||||||
else if (imem2.length)
|
else if (imem2.length)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user