Skip to content

Commit eb89e35

Browse files
committed
chore: clean up
1 parent 1395328 commit eb89e35

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nosft-core",
3-
"version": "2.5.2",
3+
"version": "2.5.1",
44
"private": false,
55
"main": "./dist/index.js",
66
"module": "./dist/index.mjs",

src/app/psbt.ts

+12-7
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ const Psbt = function (config) {
349349

350350
const spendableUtxos = ownedUtxos.filter(utxo => !selectedUtxos.some(ownedUtxo => ownedUtxo.txid === utxo.txid))
351351
.filter((x) => x.status.confirmed)
352+
.filter((x) => x.value > 10000)
352353
.filter(utxo => !utxo.inscriptionId)
353354
.sort((a, b) => b.value - a.value);
354355

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

395+
const metadata = {
396+
inputs: inputs.map((utxo, index) => ({
397+
index,
398+
type: utxo.inscriptionId ? 'ordinal' : 'cardinal',
399+
})),
400+
};
401+
394402
for (const utxo of ordinals) {
395403
psbt.addOutput({
396404
address: destinationBtcAddress,
@@ -444,7 +452,6 @@ const Psbt = function (config) {
444452
}
445453
});
446454

447-
debugger;
448455
const psbtOutputs = psbt.data.inputs.map((_, index) => {
449456
// @ts-ignore
450457
const sigHash = psbt.__CACHE.__TX.hashForWitnessV1(
@@ -472,18 +479,16 @@ const Psbt = function (config) {
472479
const final_fee = final_signed_psbt.getFee();
473480
const final_tx = final_signed_psbt.extractTransaction();
474481
const final_vbytes = final_tx.virtualSize();
475-
const final_hex = final_tx.toHex();
476482
const final_fee_rate = (final_fee / final_vbytes).toFixed(1);
477-
console.log(`Final fee rate of signed psbt is ~${final_fee_rate} sat/vbyte`);
478-
console.log('final_signed_psbt', final_signed_psbt.toHex());
479-
480-
debugger;
483+
const final_signed_hex_psbt = final_signed_psbt.toHex();
484+
console.log('final_signed_hex_psbt', final_signed_hex_psbt);
481485

482486
return {
483-
final_hex,
484487
final_fee_rate,
485488
final_fee,
489+
final_signed_hex_psbt,
486490
final_signed_psbt,
491+
metadata
487492
};
488493
},
489494

0 commit comments

Comments
 (0)