@@ -330,20 +330,6 @@ interface TxidParseError {
330330 InvalidTxid(string txid);
331331};
332332
333- /// Errors that may occur building a light client.
334- [Error]
335- interface LightClientBuilderError {
336- /// A database could not be opened or created.
337- DatabaseError(string reason);
338- };
339-
340- /// Errors that may occur sending messages to a node.
341- [Error]
342- enum LightClientError {
343- /// The node is not currently running.
344- "NodeStopped",
345- };
346-
347333// ------------------------------------------------------------------------
348334// bdk_wallet crate - types module
349335// ------------------------------------------------------------------------
@@ -1322,206 +1308,6 @@ interface AddressData {
13221308// bdk-kyoto crate
13231309// ------------------------------------------------------------------------
13241310
1325- /// Build a BIP 157/158 light client to fetch transactions for a `Wallet`.
1326- ///
1327- /// Options:
1328- /// * List of `Peer`: Bitcoin full-nodes for the light client to connect to. May be empty.
1329- /// * `connections`: The number of connections for the light client to maintain.
1330- /// * `scan_type`: Sync, recover, or start a new wallet. For more information see [`ScanType`].
1331- /// * `data_dir`: Optional directory to store block headers and peers.
1332- ///
1333- /// A note on recovering wallets. Developers should allow users to provide an
1334- /// approximate recovery height and an estimated number of transactions for the
1335- /// wallet. When determining how many scripts to check filters for, the `Wallet`
1336- /// `lookahead` value will be used. To ensure all transactions are recovered, the
1337- /// `lookahead` should be roughly the number of transactions in the wallet history.
1338- interface LightClientBuilder {
1339- /// Start a new [`LightClientBuilder`]
1340- constructor();
1341-
1342- /// The number of connections for the light client to maintain. Default is two.
1343- LightClientBuilder connections(u8 connections);
1344-
1345- /// Directory to store block headers and peers. If none is provided, the current
1346- /// working directory will be used.
1347- LightClientBuilder data_dir(string data_dir);
1348-
1349- /// Select between syncing, recovering, or scanning for new wallets.
1350- LightClientBuilder scan_type(ScanType scan_type);
1351-
1352- /// Bitcoin full-nodes to attempt a connection with.
1353- LightClientBuilder peers(sequence<Peer> peers);
1354-
1355- /// Construct a [`LightClient`] for a [`Wallet`].
1356- [Throws=LightClientBuilderError]
1357- LightClient build([ByRef] Wallet wallet);
1358- };
1359-
1360- /// A [`Client`] handles wallet updates from a [`LightNode`].
1361- interface Client {
1362- /// Return the next available log message from a node. If none is returned, the node has stopped.
1363- [Async, Throws=LightClientError]
1364- Log next_log();
1365-
1366- /// Return the next available warning message from a node. If none is returned, the node has stopped.
1367- [Async, Throws=LightClientError]
1368- Warning next_warning();
1369-
1370- /// Return an [`Update`]. This is method returns once the node syncs to the rest of
1371- /// the network or a new block has been gossiped.
1372- [Async]
1373- Update? update();
1374-
1375- /// Add scripts for the node to watch for as they are revealed. Typically used after creating
1376- /// a transaction or revealing a receive address.
1377- ///
1378- /// Note that only future blocks will be checked for these scripts, not past blocks.
1379- [Async, Throws=LightClientError]
1380- void add_revealed_scripts([ByRef] Wallet wallet);
1381-
1382- /// The minimum fee rate required to broadcast a transcation to all connected peers.
1383- [Async, Throws=LightClientError]
1384- FeeRate min_broadcast_feerate();
1385-
1386- /// Broadcast a transaction to the network, erroring if the node has stopped running.
1387- [Async, Throws=LightClientError]
1388- void broadcast([ByRef] Transaction transaction);
1389-
1390- /// Check if the node is still running in the background.
1391- [Async]
1392- boolean is_running();
1393-
1394- /// Stop the [`LightNode`]. Errors if the node is already stopped.
1395- [Async, Throws=LightClientError]
1396- void shutdown();
1397- };
1398-
1399- /// A [`LightNode`] gathers transactions for a [`Wallet`].
1400- /// To receive [`Update`] for [`Wallet`], refer to the
1401- /// [`Client`]. The [`LightNode`] will run until instructed
1402- /// to stop.
1403- interface LightNode {
1404- /// Start the node on a detached OS thread and immediately return.
1405- void run();
1406- };
1407-
1408- /// Receive a [`Client`] and [`LightNode`].
1409- dictionary LightClient {
1410- /// Publish events to the node, like broadcasting transactions or adding scripts.
1411- Client client;
1412-
1413- /// The node to run and fetch transactions for a [`Wallet`].
1414- LightNode node;
1415- };
1416-
1417- /// Sync a wallet from the last known block hash, recover a wallet from a specified height,
1418- /// or perform an expedited block header download for a new wallet.
1419- [Enum]
1420- interface ScanType {
1421- /// Perform an expedited header and filter download for a new wallet.
1422- /// If this option is not set, and the wallet has no history, the
1423- /// entire chain will be scanned for script inclusions.
1424- New();
1425-
1426- /// Sync an existing wallet from the last stored chain checkpoint.
1427- Sync();
1428-
1429- /// Recover an existing wallet by scanning from the specified height.
1430- Recovery(u32 from_height);
1431- };
1432-
1433- /// A peer to connect to over the Bitcoin peer-to-peer network.
1434- dictionary Peer {
1435- /// The IP address to reach the node.
1436- IpAddress address;
1437-
1438- /// The port to reach the node. If none is provided, the default
1439- /// port for the selected network will be used.
1440- u16? port;
1441-
1442- /// Does the remote node offer encrypted peer-to-peer connection.
1443- boolean v2_transport;
1444- };
1445-
1446- /// An IP address to connect to over TCP.
1447- interface IpAddress {
1448- /// Build an IPv4 address.
1449- [Name=from_ipv4]
1450- constructor(u8 q1, u8 q2, u8 q3, u8 q4);
1451-
1452- /// Build an IPv6 address.
1453- [Name=from_ipv6]
1454- constructor(u16 a, u16 b, u16 c, u16 d, u16 e, u16 f, u16 g, u16 h);
1455- };
1456-
1457- /// A log message from the node.
1458- [Enum]
1459- interface Log {
1460- /// A human-readable debug message.
1461- Debug(string log);
1462-
1463- /// All the required connections have been met. This is subject to change.
1464- ConnectionsMet();
1465-
1466- /// A percentage value of filters that have been scanned.
1467- Progress(f32 progress);
1468-
1469- /// A state in the node syncing process.
1470- StateUpdate(NodeState node_state);
1471-
1472- /// A transaction was broadcast over the wire.
1473- /// The transaction may or may not be rejected by recipient nodes.
1474- TxSent(string txid);
1475- };
1476-
1477- /// Warnings a node may issue while running.
1478- [Enum]
1479- interface Warning {
1480- /// The node is looking for connections to peers.
1481- NeedConnections();
1482-
1483- /// A connection to a peer timed out.
1484- PeerTimedOut();
1485-
1486- /// The node was unable to connect to a peer in the database.
1487- CouldNotConnect();
1488-
1489- /// A connection was maintained, but the peer does not signal for compact block filers.
1490- NoCompactFilters();
1491-
1492- /// The node has been waiting for new inv and will find new peers to avoid block withholding.
1493- PotentialStaleTip();
1494-
1495- /// A peer sent us a peer-to-peer message the node did not request.
1496- UnsolicitedMessage();
1497-
1498- /// The provided starting height is deeper than the database history.
1499- /// This should not occur under normal use.
1500- InvalidStartHeight();
1501-
1502- /// The headers in the database do not link together.
1503- /// Recoverable by deleting the database.
1504- CorruptedHeaders();
1505-
1506- /// A transaction got rejected, likely for being an insufficient fee or non-standard transaction.
1507- TransactionRejected(string txid, string? reason);
1508-
1509- /// A database failed to persist some data and may retry again.
1510- FailedPersistence(string warning);
1511-
1512- /// The peer sent us a potential fork.
1513- EvaluatingFork();
1514-
1515- /// The peer database has no values.
1516- EmptyPeerDatabase();
1517-
1518- /// An unexpected error occured processing a peer-to-peer message.
1519- UnexpectedSyncError(string warning);
1520-
1521- /// The node failed to respond to a message sent from the client.
1522- RequestFailed();
1523- };
1524-
15251311/// The state of the node with respect to connected peers.
15261312[Remote]
15271313enum NodeState {
0 commit comments