2.9 KiB
Double-Spends and Detecting Conflicting State
- Currently DSP's are constrained to P2PKH.
- We may be able to extend these to some P2SH - but the requirement is that the P2SH must have an
OP_CHECKSIG. - There will be at least some (potentially many) kinds of P2SH that lack an
OP_CHECKSIG. - One problem that we have is that we cannot reliably determine (with Electrum) whether a P2SH may have been double-spent.
- ???
- Lack of profit
The point you're trying to get at is that Nodes on the network can have a differing mempool state.
How do we detect that? Fulcrum can't really provide us with that information.
How do we handle it if we can detect it? E.g. avoiding any "contentious" dependencies.
Do we have to store a whole graph?
For now, do owe just broadcast to one of our nodes and then broadcast to ALL of our nodes 5s later to see if there's contention?
Electrum 4.0.1 Notes
- Maybe default constructor generic to
ElectrumClientEvents:
class ElectrumClient<ElectrumEvents extends ElectrumClientEvents = ElectrumClientEvents>
RequestResponsemight be typed incorrectly: It now takesRPCParameter | RPCParameter[]which are defined as follows:string | number | boolean | null;(note that it only accept parameters, not responses which are often/maybe-always JSON).
Previously, it would accept:
export type RequestResponse =
| object
| string
| number
| boolean
| null
| RequestResponse[];
Perhaps we could type it: export type RequestResponse = RPCParameter & object | Array<RPCParameter & object>; (replace object with something like RPCResponse, but I think that might be taken already?)
-
RPCNotificationmight be typed incorrectly (or maybe this is for future proofing?). Theparamsproperty is marked as optional (but I think all notifications will have at least one). Might be more elegant to have it required and just return an empty array. -
The current approach still requires polyfills because
@electrum/socketsitself is imported by@electrum/networkand@electrum/socketsexportsElectrumTcpSocket.A workable approach might be:
- Move socket interface back to
@electum/network. - Move the
ElectrumWebSocketback to@electrum/network. - Rename
@electrum/socketsto@electrum/tcp-socketand only include the TCP Socket in there. - This will still allow third-parties to define their own sockets (e.g.
@custom/electrum-libp2p-socket).
- Move socket interface back to
-
This is what's required for polyfilling in Vite currently:
npm install events
npm install vite-plugin-node-polyfills
[
nodePolyfills,
{
include: ['events', 'net', 'tls'],
// NOTE: Not disabling these causes an error on Vite Polyfills V0.22.
globals: {
Buffer: false,
global: false,
process: false,
},
},
],