psbt.addInput not being updated in promise. How to workaround it??
var psbt = new bitcoin.Psbt({ network: TESTNET }); var ran = []; //grab one or multiple utxos getUTXO(amt_satoshi).then((utxo_arr) => { for (let i = 0; i < utxo_arr.length; i++) { pre_output += utxo_arr[i].value; getTxHex(utxo_arr[i].txid).then((tx_hex) => { ran; ran.push(tx_hex); console.log("HEX", tx_hex);
psbt is a bitcoinjs object(transaction), addInput stays undefined.
psbt.addInput({ hash: utxo_arr[i].txid, index: i, nonWitnessUtxo: Buffer.from(tx_hex), }); });