-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Firo]: Support exchange address (#3712)
- Loading branch information
Showing
12 changed files
with
322 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// Copyright © 2017 Trust Wallet. | ||
|
||
#pragma once | ||
|
||
#include "TWBase.h" | ||
|
||
TW_EXTERN_C_BEGIN | ||
|
||
/// Firo address type. | ||
TW_EXPORT_ENUM(uint32_t) | ||
enum TWFiroAddressType { | ||
TWFiroAddressTypeDefault = 0, // default | ||
TWFiroAddressTypeExchange = 1, | ||
}; | ||
|
||
TW_EXTERN_C_END |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// Copyright © 2017 Trust Wallet. | ||
|
||
#pragma once | ||
|
||
#include "../Base58Address.h" | ||
#include "Data.h" | ||
#include "../PublicKey.h" | ||
|
||
#include <string> | ||
|
||
namespace TW::Bitcoin { | ||
|
||
// see: https://github.com/firoorg/firo/blob/8bd4abdea223e22f15c36e7d2d42618dc843e2ef/src/chainparams.cpp#L357 | ||
static const size_t kExchangeAddressSize = 23; | ||
static const Data kPrefix = {0x01, 0xb9, 0xbb}; | ||
|
||
/// Class for firo exchange addresses | ||
class ExchangeAddress : public TW::Base58Address<kExchangeAddressSize> { | ||
public: | ||
/// Initializes an address with a string representation. | ||
explicit ExchangeAddress(const std::string& string) : TW::Base58Address<kExchangeAddressSize>(string) {} | ||
|
||
/// Initializes an address with a collection of bytes. | ||
explicit ExchangeAddress(const Data& data) : TW::Base58Address<kExchangeAddressSize>(data) {} | ||
|
||
/// Initializes an address with a public key and prefix. | ||
ExchangeAddress(const PublicKey& publicKey) : TW::Base58Address<kExchangeAddressSize>(publicKey, kPrefix) {} | ||
|
||
/// Determines whether a string makes a valid Firo exchange address. | ||
static bool isValid(const std::string& string) { | ||
return TW::Base58Address<size>::isValid(string, {kPrefix}); | ||
} | ||
}; | ||
|
||
} // namespace TW::Bitcoin |
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
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
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
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.