-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: token identifiers for currencies
At a high level, this adds a concept of a token identifier for each currency supported by xud that is consistent across the entire network. "BTC" can mean mainnet tokens or testnet tokens (or simnet, etc...) and can even be misconfigured to point to the LTC lightning network. Meanwhile, Raiden ERC20 tokens refer to a particular token contract, and there's no guarantee that peers won't be using different (and therefore incompatible) contracts for the same currency such as WETH. Here, we use an identifier to ensure peers are referring to the same token as we are. For currencies that use lnd, the token identifier is determined dynamically using the `chain` and `network` returned by lnd on a `GetInfo` call. For example, BTC mainnet would be "bitcoin-mainnet" and LTC testnet would be "litecoin-testnet". For currencies that use Raiden, we use the token contract address as the identifier. These token identifiers are shared with peers during the handshake and on any subsequent node state updates. The p2p messaging format is changed to accommodate this. This also drops static node values like the `nodePubKey` and `version` from the node state p2p message, as these values can not change mid-session for a peer. A future improvement may be to detect and support discrepancies in the currency symbol used by a peer for the same token. For example, a peer that advertises "XBT" with a token identifier of "bitcoin-mainnet" should be compatible with our "BTC" that also is identified as "bitcoin-mainnet". This is not included in this commit as it would require further refactoring and complexity. Another follow-up may be creating a test suite for the `Peer` class or refactoring it to move logic elsewhere (along with tests for that logic). There is some logic around handling node state updates where information regarding the peer's supported currencies may change that is currently not tested. Closes #910. BREAKING CHANGE: Changed p2p messaging structure for `SessionInit` and `NodeStateUpdate` packets.
- Loading branch information
Showing
23 changed files
with
619 additions
and
449 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.