Signed-off-by: James Zuccon <zuccon@gmail.com>
This commit is contained in:
James Zuccon
2024-09-06 10:59:30 +10:00
parent b9a53659ce
commit f189c4643b
12 changed files with 311 additions and 13 deletions
+17
View File
@@ -1,3 +1,4 @@
import { Transaction } from '@xo/primitives';
import { AddressNotification, ElectrumRequest } from './blockchain-types.js';
import { ElectrumClient } from '@electrum-cash/network';
@@ -75,6 +76,22 @@ export class Blockchain {
return response;
}
// TODO: async commit() method
// This won't actually broadcast, this will just commit the transaction to our graph.
// The reason we want this is because, for protos like BIP70, we want service to verify the tx and broadcast it.
// And we just want to be able to monitor whether service did the needful (broadcasted it).
// This should accept options: { waitForSeen: boolean }
async commitTransaction(
transaction: Transaction,
opts: { waitUntilSeen: boolean } = { waitUntilSeen: true }
) {
console.log(transaction);
console.log(opts);
}
// TODO: async broadcast() method
// This should accept options: { waitForSeen: boolean }
async subscribeAddress(address: string, callback: AddressCallback) {
await this.electrumClient.subscribe(
'blockchain.address.subscribe',