Skip to content

Commit

Permalink
get chaintype from chain
Browse files Browse the repository at this point in the history
  • Loading branch information
loongy committed Sep 2, 2020
1 parent 25c0c7b commit 50cd544
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions multichain.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,25 @@ func (chain *Chain) Unmarshal(buf []byte, rem int) ([]byte, int, error) {
return surge.UnmarshalString((*string)(chain), buf, rem)
}

func (chain Chain) ChainType() ChainType {
switch chain {
case Bitcoin, BitcoinCash, DigiByte, Dogecoin, Zcash:
return ChainTypeUTXOBased
case BinanceSmartChain, Ethereum:
return ChainTypeAccountBased
default:
return ChainType("")
}
}

func (chain Chain) IsAccountBased() bool {
return chain.ChainType() == ChainTypeAccountBased
}

func (chain Chain) IsUTXOBased() bool {
return chain.ChainType() == ChainTypeUTXOBased
}

type ChainType string

const (
Expand Down

0 comments on commit 50cd544

Please sign in to comment.