|
19 | 19 | // See the License for the specific language governing permissions and
|
20 | 20 | // limitations under the License.
|
21 | 21 |
|
22 |
| -use bp::Address; |
| 22 | +use bp::{Address, AddressNetwork}; |
23 | 23 | use indexmap::IndexMap;
|
24 | 24 | use rgb::interface::TypedState;
|
25 | 25 | use rgb::{AttachId, Chain, ContractId, SecretSeal};
|
@@ -55,6 +55,28 @@ pub enum Beneficiary {
|
55 | 55 | WitnessUtxo(Address),
|
56 | 56 | }
|
57 | 57 |
|
| 58 | +impl Beneficiary { |
| 59 | + pub fn chain_info(&self) -> Option<Chain> { |
| 60 | + match self { |
| 61 | + Beneficiary::BlindedSeal(_) => None, |
| 62 | + Beneficiary::WitnessUtxo(Address { |
| 63 | + network: AddressNetwork::Mainnet, |
| 64 | + .. |
| 65 | + }) => Some(Chain::Bitcoin), |
| 66 | + Beneficiary::WitnessUtxo(Address { |
| 67 | + network: AddressNetwork::Regtest, |
| 68 | + .. |
| 69 | + }) => Some(Chain::Regtest), |
| 70 | + Beneficiary::WitnessUtxo(Address { |
| 71 | + network: AddressNetwork::Testnet, |
| 72 | + .. |
| 73 | + }) => Some(Chain::Testnet3), |
| 74 | + } |
| 75 | + } |
| 76 | + |
| 77 | + pub fn has_chain_info(&self) -> bool { self.chain_info().is_some() } |
| 78 | +} |
| 79 | + |
58 | 80 | #[derive(Clone, Eq, PartialEq, Debug)]
|
59 | 81 | pub struct RgbInvoice {
|
60 | 82 | pub transports: Vec<RgbTransport>,
|
|
0 commit comments