Skip to content

Commit

Permalink
chore: clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
topether21 committed May 15, 2024
1 parent 1395328 commit eb89e35
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nosft-core",
"version": "2.5.2",
"version": "2.5.1",
"private": false,
"main": "./dist/index.js",
"module": "./dist/index.mjs",
Expand Down
19 changes: 12 additions & 7 deletions src/app/psbt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ const Psbt = function (config) {

const spendableUtxos = ownedUtxos.filter(utxo => !selectedUtxos.some(ownedUtxo => ownedUtxo.txid === utxo.txid))
.filter((x) => x.status.confirmed)
.filter((x) => x.value > 10000)
.filter(utxo => !utxo.inscriptionId)
.sort((a, b) => b.value - a.value);

Expand Down Expand Up @@ -391,6 +392,13 @@ const Psbt = function (config) {
const nonOrdinals = inputs.filter(utxo => !utxo.inscriptionId);
const spendableAmount = nonOrdinals.reduce((acc, utxo) => acc + utxo.value, 0);

const metadata = {
inputs: inputs.map((utxo, index) => ({
index,
type: utxo.inscriptionId ? 'ordinal' : 'cardinal',
})),
};

for (const utxo of ordinals) {
psbt.addOutput({
address: destinationBtcAddress,
Expand Down Expand Up @@ -444,7 +452,6 @@ const Psbt = function (config) {
}
});

debugger;
const psbtOutputs = psbt.data.inputs.map((_, index) => {
// @ts-ignore
const sigHash = psbt.__CACHE.__TX.hashForWitnessV1(
Expand Down Expand Up @@ -472,18 +479,16 @@ const Psbt = function (config) {
const final_fee = final_signed_psbt.getFee();
const final_tx = final_signed_psbt.extractTransaction();
const final_vbytes = final_tx.virtualSize();
const final_hex = final_tx.toHex();
const final_fee_rate = (final_fee / final_vbytes).toFixed(1);
console.log(`Final fee rate of signed psbt is ~${final_fee_rate} sat/vbyte`);
console.log('final_signed_psbt', final_signed_psbt.toHex());

debugger;
const final_signed_hex_psbt = final_signed_psbt.toHex();
console.log('final_signed_hex_psbt', final_signed_hex_psbt);

return {
final_hex,
final_fee_rate,
final_fee,
final_signed_hex_psbt,
final_signed_psbt,
metadata
};
},

Expand Down

0 comments on commit eb89e35

Please sign in to comment.