在此代码中,client.createTransaction()
函数返回result1.txid
。我想从该result1.txid
运行 while循环,并在该 while循环内部,我想client.getTx()
重复untill i get status == 1 or -1
。在这里,我无法运行while循环。它什么也没显示
var coinPay = require('coinpayments');
var fs = require('fs');
var async = require("async");
var client = new coinPay({
'key': 'XYZsdgdfgdf',
'secret': 'XYZsdfsdfsd',
'autoIpn': true
});
client.createTransaction({
'currency1': 'LTCT',
'currency2': 'LTCT',
'amount': 1
}, (err, result1) => {
while (true) {
client.getTx(result1.txn_id, (err, result) => {
console.log(result);
if (result.status == -1) {
console.log("unsuccesful");
return;
} else if (result.status == 1) {
console.log("succesful");
return;
} else
console.log("checking");
})
}
}
)