0

我在使用 pathpaymentstrictReceive API 时遇到问题。它工作正常,但由于恒星的一些变化,它抛出错误。交易正在成功,所有交易都记录在恒星区块链上,但无法读取来自恒星交易所的响应。

enter code here
server.accounts()
.accountId(keypair.publicKey())
.call()
.then(async ({ sequence }) => {
try {
const source = new StellarSdk.Account(keypair.publicKey(), sequence);
let obj = {
sendAsset: base_asset,
sendMax: sendMax,
destination: destination,
destAsset: destination_asset,
destAmount: destAmount
}
console.log('obj is', JSON.stringify(obj))
var transaction = new StellarSdk.TransactionBuilder(source, {
fee: '1000',
networkPassphrase: process.env.NETWORK_PASSPHRASE
}).addOperation(StellarSdk.Operation.pathPaymentStrictReceive(obj))
.setTimeout(30)
.build();
console.log('console 1',transaction);
console.log('transaction in path payment',keypair.publicKey())
console.log('transaction in path payment',keypair.secret())
transaction.sign(keypair);
const transactionDetails = await server.submitTransaction(transaction);
console.log("success pathpayment");
// console.log('--@ transation is',transactionDetails)
// library.logger.debug(`transactionDetails: ${JSON.stringify(transactionDetails)}`);
// const randomUnique = new Date().getTime();
// transactionDetails.id = randomUnique;
setImmediate(cb, null, { transaction: transactionDetails });
// var sqlQuery = jsonSql.build({
// type: 'insert',
// table: 'path_payments',
// values: {
// id: randomUnique,
// base_asset: baseAsset,
// destination_asset: destinationAsset,
// sender: keypair.publicKey(),
// destination: destination,
// send_max: sender.first_name != null ? sender.first_name + ' ' + sender.last_name : sender.mobile_number,
// dest_amount: destAmount
// }
// });
// for (let key in sqlQuery.values) {
// sqlQuery.query = sqlQuery.query.replace('$' + key, '${' + key + '}');
// }
// library.db.none(sqlQuery.query, sqlQuery.values)
// .then(data => {
// library.logger.debug(`pathPayment data saved in the database.`);
// })
// .catch(err => {
// library.logger.error(`pathPayment data save error: ${err.message}`);
// });
} catch (e) {
let message = e.message
if(message.includes("Request failed with status code 400")){
message = `${e.message}: ${e.response.data.extras.result_codes.operations}`
library.logger.debug(`Error message is "${message}"`)
}
library.logger.error(`pathPaymrnt error1: ${message}, stack: ${JSON.stringify(e.stack)}`);
return setImmediate(cb, {
message: message,
stack: e.stack
});
}
})

error1:XDR 读取错误:值 1 的未知 PublicKeyType 成员,堆栈:“错误:XDR 读取错误:值 1 的未知 PublicKeyType 成员\n

4

0 回答 0