Massive changes. I dont know what happens. Rewrote the action wizard again. Fixed several bugs related to the utxo selection. QR codes were added for address. Add support for data results. Experiment with other methods of role extraction

This commit is contained in:
2026-03-22 13:20:46 +00:00
parent be52f73e64
commit a28d43a68b
35 changed files with 2226 additions and 1169 deletions

View File

@@ -17,6 +17,7 @@ import { EventEmitter } from '../utils/event-emitter.js';
// TODO: Remove this. Exists to hash the seed for database namespace.
import { createHash } from 'crypto';
import { p2pkhTemplate } from '@xo-cash/templates';
import { hexToBin } from '@bitauth/libauth';
export type AppEventMap = {
'invitation-added': Invitation;
@@ -58,6 +59,8 @@ export class AppService extends EventEmitter<AppEventMap> {
// Import the default P2PKH template
await engine.importTemplate(p2pkhTemplate);
console.log('p2pkhTemplate', JSON.stringify(p2pkhTemplate.transactions, null, 2));
// Set default locking parameters for P2PKH
// To my knowledge, this doesnt generate any lockscript, so discovery of funds will not work automatically.
// TODO: Add discovery for funds in the first index? Or until we return 0 TXs?
@@ -77,6 +80,25 @@ export class AppService extends EventEmitter<AppEventMap> {
applicationIdentifier: config.electrumApplicationIdentifier,
});
// TEMP because testing is painful
// Remove all reserved UTXOs on startup
// First, get every unspent output
const allUnspentOutputs = await engine.listUnspentOutputsData();
// Get a set of all the invitation identifiers
const allInvitationIdentifiers = new Set(allUnspentOutputs.map(output => output.invitationIdentifier));
// Iterate over the invitation identifiers and unreserve the outputs
for (const invitationIdentifier of allInvitationIdentifiers) {
// Get the outputs for the invitation
const outputs = allUnspentOutputs.filter(output => output.invitationIdentifier === invitationIdentifier);
// Unreserve the outputs
await engine.unreserveResources(outputs.map(output => ({
outpointTransactionHash: hexToBin(output.outpointTransactionHash),
outpointIndex: output.outpointIndex,
})), invitationIdentifier);
}
return new AppService(engine, walletStorage, config, electrum);
}