<p>I think these interfaces are <s>exclusively</s> used in the running of Bitcoin Core in multiprocess mode (<a href="https://github.com/bitcoin/bitcoin/blob/master/doc/design/multiprocess.md" rel="nofollow noreferrer">1</a>, <a href="https://bitcoin.stackexchange.com/questions/98398/what-is-the-motivation-behind-russell-yanofskys-work-to-separate-bitcoin-core-i/">2</a>). When running Bitcoin Core as a single process (which is the default mode) these interfaces aren't used. However, multi processes need a way for a process to communicate with another process and this is done through these well defined interfaces.</p>

CC BY-SA 4.0
2022-11-15T19:53:54.730Z
That's not correct. They're used right now already for interaction between various components (though the goal of this is having a unified interface between components, so that later those components may end up running in different processes).
Pieter Wuille
CC BY-SA 4.0
2022-11-15T20:01:40.180Z
Ok I'll wait for your answer on this then. Feel free to downvote this :)
Michael Folkson
CC BY-SA 4.0
2022-11-15T19:43:22.123Z
2022-11-15T20:54:07.637Z
2022-11-15T20:54:07.637Z
Michael Folkson
<p>The interfaces classes just provide API definitions.</p>
<p>For example the <code>interface::Wallet</code> class declares a virtual <code>interfaces::Wallet::getWalletTxs()</code> method that GUI code can call to list wallet transactions. Wallet code provides a <code>wallet::WalletImpl</code> class that inherits from <code>interfaces::Wallet</code> and provides a <code>wallet::WalletImpl::getWalletTxs()</code> implementation of that method.</p>
<p>Because of the interface definition, GUI code can call the wallet code through the interface without being linked to wallet code or even necessarily running in the same process.</p>

CC BY-SA 4.0
2022-11-15T20:50:17.023Z
2022-11-15T20:50:17.023Z
Russ Yanofsky
<p>There is a <a href="https://github.com/bitcoin/bitcoin/tree/v23.0/src/interfaces" rel="nofollow noreferrer">directory</a> called interfaces. I've seen usage of interface classes in other places but never understood how do they work because they're trivially just an interface and therefore do nothing by their own. Can someone explain the mechanism they work in the code?</p>

<bitcoin-core><bitcoin-core-development>
How are interfaces used and work in the Bitcoin Core?
Amir reza Riahi
# How are interfaces used and work in the Bitcoin Core?

(Asked by: username_0 on 2022-11-15)

There is a [directory](https://github.com/bitcoin/bitcoin/tree/v23.0/src/interfaces) called interfaces. I've seen usage of interface classes in other places but never understood how do they work because they're trivially just an interface and therefore do nothing by their own. Can someone explain the mechanism they work in the code?

**Tags:** bitcoin-core, bitcoin-core-development


---

## 2 answers

### Answer by username_3 on 2022-11-15. Score: 5 | Accepted answer

The interfaces classes just provide API definitions.

For example the `interface::Wallet` class declares a virtual `interfaces::Wallet::getWalletTxs()` method that GUI code can call to list wallet transactions. Wallet code provides a `wallet::WalletImpl` class that inherits from `interfaces::Wallet` and provides a `wallet::WalletImpl::getWalletTxs()` implementation of that method.

Because of the interface definition, GUI code can call the wallet code through the interface without being linked to wallet code or even necessarily running in the same process.


---

### Answer by username_1 on 2022-11-15. Score: 0

I think these interfaces are ~~exclusively~~ used in the running of Bitcoin Core in multiprocess mode ([1](https://github.com/bitcoin/bitcoin/blob/master/doc/design/multiprocess.md), [2](https://bitcoin.stackexchange.com/questions/98398/what-is-the-motivation-behind-russell-yanofskys-work-to-separate-bitcoin-core-i/)). When running Bitcoin Core as a single process (which is the default mode) these interfaces aren't used. However, multi processes need a way for a process to communicate with another process and this is done through these well defined interfaces.

> **Comments:**
> **username_2**: That's not correct. They're used right now already for interaction between various components (though the goal of this is having a unified interface between components, so that later those components may end up running in different processes).  
> **username_1**: Ok I'll wait for your answer on this then. Feel free to downvote this :)  

---

