Skip to content

Commit 6439e69

Browse files
authored
Merge pull request #96 from bcProFoundation/fb-takyoon-merchant-order-api-2
fix invalid slp burn error
2 parents bc7357c + f570d46 commit 6439e69

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

packages/bitcore-wallet-service/src/lib/chain/xec/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ export class XecChain extends BtcChain implements IChain {
305305

306306
// output rawhex
307307
const hex = tx.toHex();
308-
const txid = await this.broadcastRaw(wallet, hex, true);
308+
const txid = await this.broadcastRaw(wallet, hex, true, true);
309309
return txid;
310310
}
311311

@@ -346,14 +346,15 @@ export class XecChain extends BtcChain implements IChain {
346346
return tokenUtxos;
347347
}
348348

349-
public broadcastRaw(wallet, raw, ischronik) {
349+
public broadcastRaw(wallet, raw, ischronik, skipSlpCheck = false) {
350350
return new Promise((resolve, reject) => {
351351
wallet.broadcastRawTx(
352352
{
353353
rawTx: raw,
354354
network: 'livenet',
355355
coin: wallet.credentials.coin,
356-
ischronik
356+
ischronik,
357+
skipSlpCheck
357358
},
358359
(err, txid) => {
359360
if (err || !txid) return reject(err ? err : 'No Tokens');

packages/bitcore-wallet-service/src/lib/server.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3764,9 +3764,9 @@ export class WalletService {
37643764
});
37653765
}
37663766

3767-
_broadcastRawTxByChronik(chronikClient, hex, cb) {
3767+
_broadcastRawTxByChronik(chronikClient, hex, skipSlpCheck, cb) {
37683768
return chronikClient
3769-
.broadcastTx(hex)
3769+
.broadcastTx(hex, skipSlpCheck)
37703770
.then(txidObj => {
37713771
return cb(null, txidObj.txid);
37723772
})
@@ -3780,6 +3780,7 @@ export class WalletService {
37803780
* @param {Object} opts
37813781
* @param {string} [opts.coin = 'btc'] - The coin for this transaction.
37823782
* @param {string} [opts.network = 'livenet'] - The Bitcoin network for this transaction.
3783+
* @param {string} [opts.skipSlpCheck = false] - If set this prop to false, chronik will check tx doesn't burn. Default to false
37833784
* @param {string} opts.rawTx - Raw tx data.
37843785
*/
37853786
async broadcastRawTx(opts, cb) {
@@ -3795,7 +3796,7 @@ export class WalletService {
37953796
} else {
37963797
const coin = opts.coin;
37973798
const chronikClient = ChainService.getChronikClient(coin);
3798-
this._broadcastRawTxByChronik(chronikClient, opts.rawTx, async (err, txid) => {
3799+
this._broadcastRawTxByChronik(chronikClient, opts.rawTx, !!opts.skipLibCheck, async (err, txid) => {
37993800
if (err || !txid) {
38003801
logger.warn(`Broadcast failed: ${err}`);
38013802
if (err) return cb(err);
@@ -5101,7 +5102,7 @@ export class WalletService {
51015102
? `:: Actual amount convert on server : ${merchantOrder.amountCalculated} ${config.conversion.tokenCodeUnit}`
51025103
: '';
51035104
const stringConvert =
5104-
!!merchantOrder.amountFrom && merchantOrder.amountFrom > 0
5105+
!merchantOrder.isToken && !!merchantOrder.amountFrom && merchantOrder.amountFrom > 0
51055106
? `:: Not able to convert ${merchantOrder.amountFrom} ${merchantOrder.coin.toUpperCase()} to ${
51065107
merchantOrder.amount
51075108
} ${config.conversion.tokenCodeUnit}`
@@ -5504,6 +5505,10 @@ export class WalletService {
55045505
{ parse_mode: 'HTML' }
55055506
);
55065507
}
5508+
if (!!merchantOrder.listEmailContent && merchantOrder.listEmailContent.length > 2) {
5509+
let contentEmail = merchantOrder.listEmailContent[2];
5510+
bot.sendMessage(config.merchantOrder.channelSuccessId, contentEmail, { parse_mode: 'HTML' });
5511+
}
55075512
await this._handleEmailNotificationForMerchantOrder(merchantOrder);
55085513
}
55095514

0 commit comments

Comments
 (0)