beignet 0.33.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/cli/beignet-node.js +53 -7
- package/dist/cli/beignet-node.js.map +1 -1
- package/dist/cli/cli.js +5 -1
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/config.js +19 -1
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/daemon-options.js +1 -0
- package/dist/cli/daemon-options.js.map +1 -1
- package/dist/cli/daemon.js +3 -0
- package/dist/cli/daemon.js.map +1 -1
- package/dist/cli/openapi.js +50 -1
- package/dist/cli/openapi.js.map +1 -1
- package/dist/cli/routes.js +2 -0
- package/dist/cli/routes.js.map +1 -1
- package/dist/direct-funding/bitcoin-core.js +548 -0
- package/dist/direct-funding/bitcoin-core.js.map +1 -0
- package/dist/direct-funding/client.js +240 -0
- package/dist/direct-funding/client.js.map +1 -0
- package/dist/direct-funding/index.js +47 -0
- package/dist/direct-funding/index.js.map +1 -0
- package/dist/direct-funding/node.js +115 -0
- package/dist/direct-funding/node.js.map +1 -0
- package/dist/direct-funding/peer-messaging.js +314 -0
- package/dist/direct-funding/peer-messaging.js.map +1 -0
- package/dist/direct-funding/psbt.js +282 -0
- package/dist/direct-funding/psbt.js.map +1 -0
- package/dist/direct-funding/transports.js +28 -0
- package/dist/direct-funding/transports.js.map +1 -0
- package/dist/lightning/chain/hashes.js +13 -0
- package/dist/lightning/chain/hashes.js.map +1 -0
- package/dist/lightning/channel/channel-manager.js +21 -4
- package/dist/lightning/channel/channel-manager.js.map +1 -1
- package/dist/lightning/channel/types.js +5 -8
- package/dist/lightning/channel/types.js.map +1 -1
- package/dist/lightning/direct-funding/index.js +5 -2
- package/dist/lightning/direct-funding/index.js.map +1 -1
- package/dist/lightning/direct-funding/receiver/engine.js +34 -5
- package/dist/lightning/direct-funding/receiver/engine.js.map +1 -1
- package/dist/lightning/direct-funding/receiver/types.js.map +1 -1
- package/dist/lightning/direct-funding/requests.js +284 -17
- package/dist/lightning/direct-funding/requests.js.map +1 -1
- package/dist/lightning/direct-funding/sender/engine.js +5 -0
- package/dist/lightning/direct-funding/sender/engine.js.map +1 -1
- package/dist/lightning/direct-funding/types.js +5 -5
- package/dist/lightning/direct-funding/types.js.map +1 -1
- package/dist/lightning/node/config.js +1 -0
- package/dist/lightning/node/config.js.map +1 -1
- package/dist/lightning/node/lightning-node.js +106 -16
- package/dist/lightning/node/lightning-node.js.map +1 -1
- package/dist/lightning/node/types.js.map +1 -1
- package/dist/lightning/transport/peer-manager.js +67 -11
- package/dist/lightning/transport/peer-manager.js.map +1 -1
- package/dist/lightning/transport/peer.js +4 -2
- package/dist/lightning/transport/peer.js.map +1 -1
- package/dist/lightning/transport/wire-capture.js +6 -1
- package/dist/lightning/transport/wire-capture.js.map +1 -1
- package/dist/types/cli/beignet-node.d.ts +12 -1
- package/dist/types/cli/config.d.ts +2 -0
- package/dist/types/cli/routes.d.ts +4 -0
- package/dist/types/cli/types.d.ts +22 -1
- package/dist/types/direct-funding/bitcoin-core.d.ts +78 -0
- package/dist/types/direct-funding/client.d.ts +57 -0
- package/dist/types/direct-funding/index.d.ts +17 -0
- package/dist/types/direct-funding/node.d.ts +22 -0
- package/dist/types/direct-funding/peer-messaging.d.ts +62 -0
- package/dist/types/direct-funding/psbt.d.ts +27 -0
- package/dist/types/direct-funding/transports.d.ts +4 -0
- package/dist/types/lightning/chain/hashes.d.ts +11 -0
- package/dist/types/lightning/channel/channel-manager.d.ts +6 -1
- package/dist/types/lightning/channel/types.d.ts +1 -8
- package/dist/types/lightning/direct-funding/index.d.ts +2 -2
- package/dist/types/lightning/direct-funding/receiver/engine.d.ts +8 -0
- package/dist/types/lightning/direct-funding/receiver/types.d.ts +8 -0
- package/dist/types/lightning/direct-funding/requests.d.ts +80 -2
- package/dist/types/lightning/direct-funding/sender/engine.d.ts +2 -0
- package/dist/types/lightning/direct-funding/types.d.ts +54 -0
- package/dist/types/lightning/node/config.d.ts +1 -0
- package/dist/types/lightning/node/events.d.ts +4 -3
- package/dist/types/lightning/node/lightning-node.d.ts +16 -0
- package/dist/types/lightning/node/types.d.ts +13 -0
- package/dist/types/lightning/transport/peer-manager.d.ts +34 -0
- package/dist/types/lightning/transport/peer.d.ts +2 -1
- package/dist/types/lightning/transport/wire-capture.d.ts +2 -0
- package/docs/README.md +1 -0
- package/package.json +19 -2
package/README.md
CHANGED
|
@@ -37,6 +37,8 @@ console.log(wallet.getBalance());
|
|
|
37
37
|
|
|
38
38
|
From here: [the on-chain wallet](#on-chain-wallet) for sending, PSBTs, multisig and watch-only, or [Lightning](#lightning) for channels and payments.
|
|
39
39
|
|
|
40
|
+
For adding `bgnq` direct-funding payments to another wallet, see the [standalone TypeScript payer SDK](packages/direct-funding/README.md). It includes a PSBT signing adapter, Bitcoin Core integration, and a channel-free peer client.
|
|
41
|
+
|
|
40
42
|
## Try the examples
|
|
41
43
|
|
|
42
44
|
The fastest way to understand the whole system is to run the two REPL examples against a live wallet and a live node. Both are checked-in TypeScript you can read and edit.
|
|
@@ -694,6 +696,8 @@ npm run test:conformance # 300+ official BOLT vector cases (subset of test:lig
|
|
|
694
696
|
npm run test:chaos # recovery kill matrices (parallel), split out of test:lightning
|
|
695
697
|
npm run test:sigkill # process-level SIGKILL chaos matrix (builds dist first)
|
|
696
698
|
npm run test:api # exported API vs tests/api-snapshot (npm run api:snapshot regenerates it)
|
|
699
|
+
npm run test:direct-funding # standalone payer SDK, wallet adapters and packaging
|
|
700
|
+
npm run test:direct-funding:regtest # real Core wallets and funding transactions (needs Docker)
|
|
697
701
|
npm run test:integration # daemon/Electrum integration (needs an Electrum server)
|
|
698
702
|
npm run test:interop # 300+ cases vs LND/CLN/Eclair (needs Docker)
|
|
699
703
|
npm run test:interop:ffor # FFOR Variant D chain gates on regtest (needs only the bitcoind container)
|
package/dist/cli/beignet-node.js
CHANGED
|
@@ -2138,6 +2138,7 @@ class BeignetNode extends typed_emitter_1.TypedEmitter {
|
|
|
2138
2138
|
chainBackend: electrumBackend,
|
|
2139
2139
|
feeEstimator: electrumBackend,
|
|
2140
2140
|
logger: this.logger,
|
|
2141
|
+
wireTrace: opts.wireTrace,
|
|
2141
2142
|
sweepDestinationScript,
|
|
2142
2143
|
socks5Proxy,
|
|
2143
2144
|
socks5ProxyScope,
|
|
@@ -2552,8 +2553,22 @@ class BeignetNode extends typed_emitter_1.TypedEmitter {
|
|
|
2552
2553
|
});
|
|
2553
2554
|
});
|
|
2554
2555
|
// Forward peer events
|
|
2556
|
+
// Connects and disconnects are logged at info: a peer that evicts us
|
|
2557
|
+
// (eclair's max-no-channels) and the auto reconnect after it are
|
|
2558
|
+
// otherwise invisible at the level a daemon runs at.
|
|
2555
2559
|
this.node.on('peer:connect', (pubkey) => {
|
|
2556
|
-
|
|
2560
|
+
let direction;
|
|
2561
|
+
try {
|
|
2562
|
+
direction = this.node.getPeerManager()?.getConnectionInfo(pubkey)
|
|
2563
|
+
?.direction;
|
|
2564
|
+
}
|
|
2565
|
+
catch {
|
|
2566
|
+
// The log line must not cost the gossip sync below.
|
|
2567
|
+
}
|
|
2568
|
+
this.log('info', 'Peer connected', {
|
|
2569
|
+
pubkey,
|
|
2570
|
+
...(direction ? { direction } : {})
|
|
2571
|
+
});
|
|
2557
2572
|
// Pull the gossip graph from the peer so we can route multi-hop payments
|
|
2558
2573
|
// to destinations beyond our direct channels. Without this the graph
|
|
2559
2574
|
// stays empty and only direct-peer payments work.
|
|
@@ -2587,9 +2602,23 @@ class BeignetNode extends typed_emitter_1.TypedEmitter {
|
|
|
2587
2602
|
}
|
|
2588
2603
|
this.emit('peer:connect', { pubkey });
|
|
2589
2604
|
});
|
|
2590
|
-
this.node.on('peer:disconnect', (pubkey) => {
|
|
2591
|
-
|
|
2592
|
-
|
|
2605
|
+
this.node.on('peer:disconnect', (pubkey, info) => {
|
|
2606
|
+
// Subscribers (SSE, webhooks, an embedding app's diagnostics)
|
|
2607
|
+
// get the same cause the log line names.
|
|
2608
|
+
const cause = info
|
|
2609
|
+
? {
|
|
2610
|
+
closedBy: info.initiator === 'remote'
|
|
2611
|
+
? 'peer'
|
|
2612
|
+
: 'us',
|
|
2613
|
+
...(info.reason ? { reason: info.reason } : {}),
|
|
2614
|
+
direction: info.direction,
|
|
2615
|
+
...(info.uptimeMs !== undefined
|
|
2616
|
+
? { uptimeMs: info.uptimeMs }
|
|
2617
|
+
: {})
|
|
2618
|
+
}
|
|
2619
|
+
: {};
|
|
2620
|
+
this.log('info', 'Peer disconnected', { pubkey, ...cause });
|
|
2621
|
+
this.emit('peer:disconnect', { pubkey, ...cause });
|
|
2593
2622
|
});
|
|
2594
2623
|
// The transport error that caused a disconnect (pong timeout, decrypt
|
|
2595
2624
|
// failure, socket reset, ...) is the only place the reason is known —
|
|
@@ -6844,6 +6873,11 @@ class BeignetNode extends typed_emitter_1.TypedEmitter {
|
|
|
6844
6873
|
if (!channel)
|
|
6845
6874
|
return null;
|
|
6846
6875
|
const state = channel.getFullState();
|
|
6876
|
+
// Nothing clears preReestablishState when a marked channel closes, so
|
|
6877
|
+
// it names the earlier state only while the channel is still wrapped.
|
|
6878
|
+
const wrappedState = state.state === types_7.ChannelState.AWAITING_REESTABLISH
|
|
6879
|
+
? state.preReestablishState
|
|
6880
|
+
: null;
|
|
6847
6881
|
// Mid-negotiation v2 channels are keyed by temporary id in the peer map
|
|
6848
6882
|
// (see buildChannelInfo); fall back so diagnostics name the peer too.
|
|
6849
6883
|
const peerPubkey = this.node.getChannelManager().getPeerForChannel(channelIdBuf) ||
|
|
@@ -6876,9 +6910,9 @@ class BeignetNode extends typed_emitter_1.TypedEmitter {
|
|
|
6876
6910
|
if (state.fundingUnaccounted === true)
|
|
6877
6911
|
issues.push('FUNDING_UNACCOUNTED: Neither mempool nor chain can account for the funding transaction, so the channel takes no new HTLCs. Routing hints will be skipped. Existing HTLCs still settle, and the quarantine lifts by itself if the funding reappears.');
|
|
6878
6912
|
if (state.state !== 'NORMAL' &&
|
|
6879
|
-
|
|
6913
|
+
wrappedState !== 'NORMAL' &&
|
|
6880
6914
|
!acceptsNewThrough) {
|
|
6881
|
-
issues.push(`NOT_NORMAL: Channel state is ${state.state} (pre-reestablish: ${
|
|
6915
|
+
issues.push(`NOT_NORMAL: Channel state is ${state.state} (pre-reestablish: ${wrappedState || 'none'}). Routing hints require a usable channel.`);
|
|
6882
6916
|
}
|
|
6883
6917
|
if (!state.announceChannel)
|
|
6884
6918
|
issues.push('PRIVATE_CHANNEL: Channel is private (not announced). Routing hints are required for payments.');
|
|
@@ -6892,7 +6926,7 @@ class BeignetNode extends typed_emitter_1.TypedEmitter {
|
|
|
6892
6926
|
channelId,
|
|
6893
6927
|
peerPubkey,
|
|
6894
6928
|
state: state.state,
|
|
6895
|
-
preReestablishState:
|
|
6929
|
+
preReestablishState: wrappedState || null,
|
|
6896
6930
|
isPeerConnected,
|
|
6897
6931
|
announceChannel: state.announceChannel,
|
|
6898
6932
|
announcementSigsSent: state.announcementSigsSent || false,
|
|
@@ -6960,6 +6994,8 @@ class BeignetNode extends typed_emitter_1.TypedEmitter {
|
|
|
6960
6994
|
capacitySats: Number(ch.fundingSatoshis),
|
|
6961
6995
|
isAnchor: (0, types_7.isAnchorChannel)(ch.channelType ?? null)
|
|
6962
6996
|
};
|
|
6997
|
+
if (ch.preReestablishState)
|
|
6998
|
+
info.preReestablishState = ch.preReestablishState;
|
|
6963
6999
|
// What the connected peer's init negotiated, read rather than guessed:
|
|
6964
7000
|
// a client deciding whether to offer splice controls has no other way
|
|
6965
7001
|
// to know, and reconstructing feature bits client-side is exactly the
|
|
@@ -7578,6 +7614,16 @@ class BeignetNode extends typed_emitter_1.TypedEmitter {
|
|
|
7578
7614
|
listDirectFundingPayments() {
|
|
7579
7615
|
return this.directFundingSender?.payments() ?? [];
|
|
7580
7616
|
}
|
|
7617
|
+
/**
|
|
7618
|
+
* Every payment received against a request this node minted, newest first
|
|
7619
|
+
* (issue #1893). `receiptHash` is the `paymentHash` the request was minted
|
|
7620
|
+
* with. Kept after the request itself expires, so a client can still tell
|
|
7621
|
+
* its request was paid: a direct-funding payment settles no invoice and pays
|
|
7622
|
+
* no address, and REVERTED means the splice it went into was undone.
|
|
7623
|
+
*/
|
|
7624
|
+
listDirectFundingReceived() {
|
|
7625
|
+
return this.node.getDirectFundingRequests()?.received() ?? [];
|
|
7626
|
+
}
|
|
7581
7627
|
/**
|
|
7582
7628
|
* Map a coded protocol refusal onto the daemon's error vocabulary. The codes
|
|
7583
7629
|
* are carried through verbatim: they are what tells the app a refusal to
|