bug fix: new line in floData causes error
since newline char is not supported in floData, new line (\n) is replaced with space.
This commit is contained in:
parent
18ddc93477
commit
ab9d695fa9
@ -8361,22 +8361,22 @@
|
||||
},
|
||||
|
||||
//Write Data into blockchain
|
||||
writeData: function (senderAddr, Data, PrivKey, receiverAddr) {
|
||||
writeData: function (senderAddr, data, privKey, receiverAddr) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.sendTx(senderAddr, receiverAddr, floGlobals.sendAmt, PrivKey, Data)
|
||||
this.sendTx(senderAddr, receiverAddr, floGlobals.sendAmt, privKey, data)
|
||||
.then(txid => resolve(txid))
|
||||
.catch(error => reject(error))
|
||||
});
|
||||
},
|
||||
|
||||
//Send Tx to blockchain
|
||||
sendTx: function (senderAddr, receiverAddr, sendAmt, PrivKey, floData = '') {
|
||||
sendTx: function (senderAddr, receiverAddr, sendAmt, privKey, floData = '') {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!floCrypto.validateAddr(senderAddr))
|
||||
reject(`Invalid address : ${senderAddr}`);
|
||||
else if (!floCrypto.validateAddr(receiverAddr))
|
||||
reject(`Invalid address : ${receiverAddr}`);
|
||||
if (PrivKey.length < 1 || !floCrypto.verifyPrivKey(PrivKey, senderAddr))
|
||||
if (privKey.length < 1 || !floCrypto.verifyPrivKey(privKey, senderAddr))
|
||||
reject("Invalid Private key!");
|
||||
else if (typeof sendAmt !== 'number' || sendAmt <= 0)
|
||||
reject(`Invalid sendAmt : ${sendAmt}`);
|
||||
@ -8399,8 +8399,8 @@
|
||||
var change = utxoAmt - sendAmt - fee;
|
||||
if (change > 0)
|
||||
trx.addoutput(senderAddr, change);
|
||||
trx.addflodata(floData);
|
||||
var signedTxHash = trx.sign(PrivKey, 1);
|
||||
trx.addflodata(floData.replace(/\n/g,' '));
|
||||
var signedTxHash = trx.sign(privKey, 1);
|
||||
this.broadcastTx(signedTxHash)
|
||||
.then(txid => resolve(txid))
|
||||
.catch(error => reject(error))
|
||||
@ -8431,7 +8431,7 @@
|
||||
}
|
||||
}
|
||||
trx.addoutput(floID, utxoAmt - fee);
|
||||
trx.addflodata(floData);
|
||||
trx.addflodata(floData.replace(/\n/g,' '));
|
||||
var signedTxHash = trx.sign(privKey, 1);
|
||||
this.broadcastTx(signedTxHash)
|
||||
.then(txid => resolve(txid))
|
||||
@ -8616,7 +8616,7 @@
|
||||
}
|
||||
for (floID in receivers)
|
||||
trx.addoutput(floID, receivers[floID]);
|
||||
trx.addflodata(floData);
|
||||
trx.addflodata(floData.replace(/\n/g,' '));
|
||||
for (let i = 0; i < wifSeq.length; i++)
|
||||
trx.signinput(i, wifSeq[i], 1);
|
||||
var signedTxHash = trx.serialize();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user